Remove more unused attributes

This commit is contained in:
Adam Hathcock
2025-03-06 11:59:13 +00:00
parent c784fbf462
commit d7bf324029
5 changed files with 13 additions and 61 deletions
+8 -8
View File
@@ -31,7 +31,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
/// <summary>
/// Gets or sets the flat list of numbers representing the <see cref="Brep"/>'s surfaces.
/// </summary>
[DetachProperty, SchemaIgnore, Chunkable(31250)]
[DetachProperty, Chunkable(31250)]
public List<double> SurfacesValue
{
get
@@ -77,7 +77,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
/// <remarks>
/// This is only used for the <see cref="Brep"/> class serialisation/deserialisation. You should use <see cref="Brep.Curve3D"/> instead.
/// </remarks>
[DetachProperty, SchemaIgnore, Chunkable(31250)]
[DetachProperty, Chunkable(31250)]
public List<double> Curve3DValues
{
get => CurveArrayEncodingExtensions.ToArray(Curve3D);
@@ -102,7 +102,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
/// <remarks>
/// This is only used for the <see cref="Brep"/> class serialisation/deserialisation. You should use <see cref="Brep.Curve2D"/> instead.
/// </remarks>
[DetachProperty, SchemaIgnore, Chunkable(31250)]
[DetachProperty, Chunkable(31250)]
public List<double> Curve2DValues
{
get => CurveArrayEncodingExtensions.ToArray(Curve2D);
@@ -127,7 +127,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
/// <remarks>
/// This is only used for the <see cref="Brep"/> class serialisation/deserialisation. You should use <see cref="Brep.Vertices"/> instead.
/// </remarks>
[DetachProperty, SchemaIgnore, Chunkable(31250)]
[DetachProperty, Chunkable(31250)]
public List<double> VerticesValue
{
get
@@ -167,7 +167,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
/// <remarks>
/// This is only used for the <see cref="Brep"/> class serialisation/deserialisation. You should use <see cref="Brep.Edges"/> instead.
/// </remarks>
[DetachProperty, SchemaIgnore, Chunkable(62500)]
[DetachProperty, Chunkable(62500)]
public List<double?> EdgesValue
{
get =>
@@ -241,7 +241,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
/// <remarks>
/// This is only used for the <see cref="Brep"/> class serialisation/deserialisation. You should use <see cref="Brep.Loops"/> instead.
/// </remarks>
[DetachProperty, SchemaIgnore, Chunkable(62500)]
[DetachProperty, Chunkable(62500)]
public List<int> LoopsValue
{
get =>
@@ -297,7 +297,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
/// <remarks>
/// This is only used for the <see cref="Brep"/> class serialisation/deserialisation. You should use <see cref="Brep.Trims"/> instead.
/// </remarks>
[DetachProperty, SchemaIgnore, Chunkable(62500)]
[DetachProperty, Chunkable(62500)]
public List<int> TrimsValue
{
get
@@ -363,7 +363,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
/// <remarks>
/// This is only used for the <see cref="Brep"/> class serialisation/deserialisation. You should use <see cref="Brep.Faces"/> instead.
/// </remarks>
[DetachProperty, SchemaIgnore, Chunkable(62500)]
[DetachProperty, Chunkable(62500)]
public List<int> FacesValue
{
get =>
-15
View File
@@ -1,15 +0,0 @@
namespace Speckle.Sdk.Host;
// TODO: this could be nuked, as it's only used to hide props on Base,
// which we might want to expose anyways...
/// <summary>
/// Used to ignore properties from expand objects etc
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public sealed class SchemaIgnoreAttribute : Attribute;
[AttributeUsage(AttributeTargets.Method)]
public sealed class SchemaComputedAttribute(string name) : Attribute
{
public string Name { get; } = name;
}
+1 -8
View File
@@ -28,20 +28,17 @@ public class Base : DynamicBase, ISpeckleObject
/// <summary>
/// A speckle object's id is an unique hash based on its properties. <b>NOTE: this field will be null unless the object was deserialised from a source. Use the <see cref="GetId"/> function to get it.</b>
/// </summary>
[SchemaIgnore]
public virtual string? id { get; set; }
/// <summary>
/// Secondary, ideally host application driven, object identifier.
/// </summary>
[SchemaIgnore]
public string? applicationId { get; set; }
/// <summary>
/// Holds the type information of this speckle object, derived automatically
/// from its assembly name and inheritance.
/// </summary>
[SchemaIgnore]
public virtual string speckle_type
{
get
@@ -210,11 +207,7 @@ public class Base : DynamicBase, ISpeckleObject
myDuplicate.id = id;
myDuplicate.applicationId = applicationId;
foreach (
var kvp in GetMembers(
DynamicBaseMemberType.Instance | DynamicBaseMemberType.Dynamic | DynamicBaseMemberType.SchemaIgnored
)
)
foreach (var kvp in GetMembers())
{
var propertyInfo = type.GetProperty(kvp.Key);
if (propertyInfo is not null && !propertyInfo.CanWrite)
+1 -20
View File
@@ -1,7 +1,6 @@
using System.Dynamic;
using System.Reflection;
using Speckle.Newtonsoft.Json;
using Speckle.Sdk.Common;
using Speckle.Sdk.Host;
namespace Speckle.Sdk.Models;
@@ -233,16 +232,12 @@ public class DynamicBase : DynamicObject, IDynamicMetaObjectProvider
.GetBaseProperties(GetType())
.Where(x =>
{
var hasIgnored = x.IsDefined(typeof(SchemaIgnoreAttribute), true);
var hasObsolete = x.IsDefined(typeof(ObsoleteAttribute), true);
// If obsolete is false and prop has obsolete attr
// OR
// If schemaIgnored is true and prop has schemaIgnore attr
return !(
!includeMembers.HasFlag(DynamicBaseMemberType.SchemaIgnored) && hasIgnored
|| !includeMembers.HasFlag(DynamicBaseMemberType.Obsolete) && hasObsolete
);
return !(!includeMembers.HasFlag(DynamicBaseMemberType.Obsolete) && hasObsolete);
});
foreach (var pi in pinfos)
{
@@ -252,20 +247,6 @@ public class DynamicBase : DynamicObject, IDynamicMetaObjectProvider
}
}
}
if (includeMembers.HasFlag(DynamicBaseMemberType.SchemaComputed))
{
GetType()
.GetMethods()
.Where(e => e.IsDefined(typeof(SchemaComputedAttribute)) && !e.IsDefined(typeof(ObsoleteAttribute)))
.ToList()
.ForEach(e =>
{
var attr = e.GetCustomAttribute<SchemaComputedAttribute>().NotNull();
dic[attr.Name] = e.Invoke(this, null);
});
}
return dic;
}
@@ -1,5 +1,3 @@
using Speckle.Sdk.Host;
namespace Speckle.Sdk.Models;
/// <summary>
@@ -23,23 +21,18 @@ public enum DynamicBaseMemberType
/// </summary>
Obsolete = 4,
/// <summary>
/// The typed members flagged with <see cref="SchemaIgnoreAttribute"/> attribute.
/// </summary>
SchemaIgnored = 8,
/// <summary>
/// The typed methods flagged with TODO:
/// </summary>
SchemaComputed = 16,
/// <summary>
/// All the typed members, including ones with <see cref="ObsoleteAttribute"/> or <see cref="SchemaIgnoreAttribute"/> attributes.
/// All the typed members, including ones with <see cref="ObsoleteAttribute"/> attributes.
/// </summary>
InstanceAll = Instance + Obsolete + SchemaIgnored,
InstanceAll = Instance + Obsolete,
/// <summary>
/// All the members, including dynamic and instance members flagged with <see cref="ObsoleteAttribute"/> or <see cref="SchemaIgnoreAttribute"/> attributes
/// All the members, including dynamic and instance members flagged with <see cref="ObsoleteAttribute"/> attributes
/// </summary>
All = InstanceAll + Dynamic,
}