Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(objects): CNX-8709 suppress warnings in obsolete classes, methods, and fields #3143

Merged
merged 15 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/Core/Models/GraphTraversal/DefaultTraversal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public static IEnumerable<string> DisplayValueAndElementsAliases(Base _)
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Obsolete")]
public static IReadOnlyList<string> geometryPropAliases => GeometryPropAliases;

[Obsolete("Renamed to " + nameof(GeometryPropAliases))]
[Obsolete("Renamed to " + nameof(DisplayValueAndElementsPropAliases))]
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Obsolete")]
[SuppressMessage("Performance", "CA1819:Properties should not return arrays", Justification = "Obsolete")]
public static string[] displayValueAndElementsPropAliases => DisplayValueAndElementsPropAliases;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,9 @@ public Polyline PolylineToSpeckle(Polyline3d polyline)
public Polyline3d PolylineToNativeDB(Polyline polyline)
{
var vertices = new Point3dCollection();
for (int i = 0; i < polyline.points.Count; i++)
foreach (Point point in polyline.GetPoints())
{
vertices.Add(PointToNative(polyline.points[i]));
vertices.Add(PointToNative(point));
}

return new Polyline3d(Poly3dType.SimplePoly, vertices, polyline.closed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,25 +129,21 @@ public CifGM.Alignment AlignmentToNative(Alignment alignment)
{
ICurve singleBaseCurve;

if (alignment.baseCurve is ICurve basecurve)
if (alignment.curves?.Count > 0)
{
singleBaseCurve = basecurve;
}
else if (alignment?.curves?.Any() is null)
{
return null;
//Not 100% clear on how best to handle the conversion between multiple curves and single element
singleBaseCurve = alignment.curves.Count == 1 ? alignment.curves.Single() : new Polycurve()
{
segments = alignment.curves
};
}
else if (alignment.curves?.Count == 1)
else if (alignment.baseCurve is not null) // this could be an old alignment using a basecurve
{
singleBaseCurve = alignment.curves.Single();
singleBaseCurve = alignment.baseCurve;
}
else
{
//Not 100% clear on how best to handle the conversion between multiple curves and single element
singleBaseCurve = new Polycurve()
{
segments = alignment.curves
};
throw new ArgumentException("Alignment had no usable curves or basecurve");
}

var nativeCurve = CurveToNative(singleBaseCurve);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public DS.Plane PlaneToNative(Plane plane)

public CoordinateSystem TransformToNative(Transform transform)
{
return CoordinateSystem.ByMatrix(transform.value).Scale(Units.GetConversionFactor(transform.units, ModelUnits));
return CoordinateSystem.ByMatrix(transform.ToArray()).Scale(Units.GetConversionFactor(transform.units, ModelUnits));
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ public object ConvertToNativeObject(Base @object)
}
// non revit built elems
case BE.Alignment o:
if (o.curves is null) // TODO: remove after a few releases, this is for backwards compatibility
if (o.curves is null && o.baseCurve is not null) // This is for backwards compatibility for the deprecated basecurve property
{
return ModelCurveToNative(o.baseCurve);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public string GetSpeckleObjectBuiltInCategory(Base @object)
return BuiltInCategory.OST_Columns.ToString();
case BE.Pipe _:
return BuiltInCategory.OST_PipeSegments.ToString();
case BE.RebarGroup<BE.RebarShape> _:
return BuiltInCategory.OST_Rebar.ToString();
case BE.Rebar _:
return BuiltInCategory.OST_Rebar.ToString();
case BE.Topography _:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public ApplicationObject DuctToNative(BuiltElements.Duct speckleDuct)
}

Element duct = null;
if (speckleDuct.baseCurve == null || speckleDuct.baseCurve is Line)
if (speckleDuct.baseCurve is Line || speckleDuct.baseLine is not null) // this is for old ducts with deprecated baseline field
{
DuctType ductType = GetElementType<DuctType>(speckleDuct, appObj, out bool _);
if (ductType == null)
Expand All @@ -52,10 +52,10 @@ public ApplicationObject DuctToNative(BuiltElements.Duct speckleDuct)
return appObj;
}

DB.Line baseLine =
(speckleDuct.baseCurve != null)
? LineToNative(speckleDuct.baseCurve as Line)
: LineToNative(speckleDuct.baseLine);
DB.Line baseLine = speckleDuct.baseCurve is Line baseCurve
? LineToNative(baseCurve)
: LineToNative(speckleDuct.baseLine);

XYZ startPoint = baseLine.GetEndPoint(0);
XYZ endPoint = baseLine.GetEndPoint(1);
DB.Level lineLevel = ConvertLevelToRevit(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,20 @@ public Other.RenderMaterial RenderMaterialToSpeckle(Rhino.Render.RenderMaterial
public Hatch[] HatchToNative(Other.Hatch hatch)
{
var curves = new List<Curve>();
curves =
hatch.loops != null
? hatch.loops.Select(o => CurveToNative(o.Curve)).ToList()
: hatch.curves.Select(o => CurveToNative(o)).ToList();
if (hatch.loops != null)
{
curves = hatch.loops.Select(o => CurveToNative(o.Curve)).ToList();
}
else if (hatch.curves is not null) // this could've been an old hatch, using the deprecated loops property
{
curves = hatch.curves.Select(o => CurveToNative(o))?.ToList();
}

if (curves.Count == 0)
{
throw new ArgumentException("Hatch did not contain any loops or curves.");
}

var pattern = Doc.HatchPatterns.FindName(hatch.pattern);
int index;
if (pattern == null)
Expand Down
8 changes: 3 additions & 5 deletions Objects/Objects/BuiltElements/Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ namespace Objects.BuiltElements;
/// <remarks>
/// Network <see cref="elements"/> may need to be created first in native applications before they are linked.
/// </remarks>
[Obsolete("Networks are no longer used in any connector to assemble MEP systems.")]
public class Network : Base
{
[Obsolete(
"The Network was previously used to assemble MEP systems, but now MEP systems are assembled by the RevitCommitObjectBuilder as MEP elements are converted."
)]
public Network() { }

public string name { get; set; }
Expand All @@ -32,9 +30,9 @@ public class Network : Base
public List<NetworkLink> links { get; set; }
}

[Obsolete("Networks are no longer used in any connector to assemble MEP systems.")]
public class NetworkElement : Base
{
[Obsolete("The NetworkElement class is obsolete because the Network class is now obsolete")]
public NetworkElement() { }

public string name { get; set; }
Expand Down Expand Up @@ -65,9 +63,9 @@ public class NetworkElement : Base
#pragma warning restore CS8619 // Nullability of reference types in value doesn't match target type. Reason: obsolete.
}

[Obsolete("Networks are no longer used in any connector to assemble MEP systems.")]
public class NetworkLink : Base
{
[Obsolete("The NetworkLink class is obsolete because the Network class is now obsolete")]
public NetworkLink() { }

public string name { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions Objects/Objects/BuiltElements/Pipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class Pipe : Base, IDisplayValue<List<Mesh>>
this.baseCurve = baseCurve;
this.length = length;
this.diameter = diameter;
this["flowRate"] = flowrate;
this["relativeRoughness"] = relativeRoughness;
}

public ICurve baseCurve { get; set; }
Expand Down
15 changes: 15 additions & 0 deletions Objects/Objects/BuiltElements/Revit/FreeformElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public FreeformElement(List<Base> baseGeometries, string subcategory = "", List<
/// It will set the first item on the baseGeometries list, and instantiate a list if necessary.
/// </summary>
[JsonIgnore, SchemaIgnore, Obsolete("Use 'baseGeometries' instead", true)]
[System.Diagnostics.CodeAnalysis.SuppressMessage(
"Design",
"CA1044:Properties should not be write only",
Justification = "Obsolete"
)]
public Base baseGeometry
{
set
Expand Down Expand Up @@ -92,6 +97,11 @@ public bool IsValidObject(Base @base)
"Families"
)
]
[System.Diagnostics.CodeAnalysis.SuppressMessage(
"Usage",
"CA2201:Do not raise reserved exception types",
Justification = "Obsolete"
)]
public FreeformElement(Base baseGeometry, List<Parameter>? parameters = null)
{
if (!IsValidObject(baseGeometry))
Expand All @@ -112,6 +122,11 @@ public FreeformElement(Base baseGeometry, List<Parameter>? parameters = null)
"Families"
)
]
[System.Diagnostics.CodeAnalysis.SuppressMessage(
"Usage",
"CA2201:Do not raise reserved exception types",
Justification = "Obsolete"
)]
public FreeformElement(List<Base> baseGeometries, List<Parameter>? parameters = null)
{
this.baseGeometries = baseGeometries;
Expand Down
8 changes: 6 additions & 2 deletions Objects/Objects/BuiltElements/Revit/RevitCeiling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public class RevitCeiling : Ceiling
public RevitCeiling() { }

[SchemaDeprecated, SchemaInfo("RevitCeiling", "Creates a Revit ceiling", "Revit", "Architecture")]
[System.Diagnostics.CodeAnalysis.SuppressMessage(
"Style",
"IDE0060:Remove unused parameter",
Justification = "Obsolete"
)]
public RevitCeiling(
[SchemaMainParam, SchemaParamInfo("Planar boundary curve")] ICurve outline,
string family,
Expand All @@ -29,7 +34,6 @@ public class RevitCeiling : Ceiling
this.level = level;
this.slope = slope;
this.slopeDirection = slopeDirection;
this.offset = offset;
this.voids = voids ?? new();
this.elements = elements;
}
Expand Down Expand Up @@ -62,7 +66,7 @@ public class RevitCeiling : Ceiling
public double slope { get; set; }
public Line? slopeDirection { get; set; }

[Obsolete("Offset property is now captured in parameters to match the behavior of other Revit objects")]
[Obsolete("Offset property is now captured in parameters to match the behavior of other Revit objects", true)]
JR-Morgan marked this conversation as resolved.
Show resolved Hide resolved
public double offset { get; set; }

public Base parameters { get; set; }
Expand Down
11 changes: 5 additions & 6 deletions Objects/Objects/BuiltElements/Revit/RevitColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class RevitColumn : Column
this.topLevel = topLevel;
this.baseOffset = baseOffset;
this.topOffset = topOffset;
//this.structural = structural;
this.rotation = rotation;
this.parameters = parameters?.ToBase();
this.level = level;
Expand All @@ -53,6 +52,11 @@ public class RevitColumn : Column
SchemaDeprecated,
SchemaInfo("RevitColumn Slanted (old)", "Creates a slanted Revit Column by curve.", "Revit", "Structure")
]
[System.Diagnostics.CodeAnalysis.SuppressMessage(
"Style",
"IDE0060:Remove unused parameter",
Justification = "Obsolete"
)]
public RevitColumn(
string family,
string type,
Expand All @@ -66,7 +70,6 @@ public class RevitColumn : Column
this.type = type;
this.baseLine = baseLine;
this.level = level;
//this.structural = structural;
isSlanted = true;
this.parameters = parameters?.ToBase();
}
Expand All @@ -87,7 +90,6 @@ public class RevitColumn : Column
this.baseLine = baseLine;
this.level = level;
this.topLevel = topLevel;
//this.structural = structural;
isSlanted = true;
this.parameters = parameters?.ToBase();
}
Expand All @@ -102,10 +104,7 @@ public class RevitColumn : Column
public double baseOffset { get; set; }
public double topOffset { get; set; }
public bool facingFlipped { get; set; }

public bool handFlipped { get; set; }

//public bool structural { get; set; }
public double rotation { get; set; }
public bool isSlanted { get; set; }
public string family { get; set; }
Expand Down
7 changes: 6 additions & 1 deletion Objects/Objects/BuiltElements/Revit/RevitNetwork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

namespace Objects.BuiltElements.Revit;

[Obsolete(
"Networks are no longer used to assemble MEP systems in Revit. See the RevitCommitBuilder for MEP systems conversion."
)]
public class RevitNetworkElement : NetworkElement
{
[Obsolete("The RevitNetworkElement class is obsolete because the Network class is now obsolete")]
public RevitNetworkElement() { }

/// <summary>
Expand All @@ -22,6 +24,9 @@ public class RevitNetworkElement : NetworkElement
public bool isConnectorBased { get; set; }
}

[Obsolete(
"Networks are no longer used to assemble MEP systems in Revit. See the RevitCommitBuilder for MEP systems conversion."
)]
public class RevitNetworkLink : NetworkLink
{
public double height { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Objects/Objects/BuiltElements/Revit/RevitRebar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class RevitRebarHook : RebarHook
}

#region Obsolete
[Obsolete("Deprecated in 2.17: Use RevitRebarGroup class instead", true)]
[Obsolete("Deprecated in 2.17: Use RevitRebarGroup class instead")]
public class RevitRebar : Rebar
{
public string family { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Objects/Objects/BuiltElements/Space.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Space(string name, string number, [SchemaMainParam] Point basePoint, Leve
// add the zone object for better forward compatibility
public RevitZone? zone { get; set; }

[Obsolete]
[Obsolete("Use zone property instead")]
public string zoneName { get; internal set; }
public string units { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class Hook : Base
}

[Obsolete("Deprecated in 2.17: set starthook and endhook to null or refer to hook angle instead")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Obsolete")]
public enum shape
{
NO_HOOK = 0,
Expand Down
Loading