Use of obsolete members now generates warning (#378)
* Use of obsolete members now generates warning * format --------- Co-authored-by: Claire Kuang <kuang.claire@gmail.com>
This commit is contained in:
@@ -255,8 +255,6 @@ dotnet_diagnostic.ca1509.severity = warning # Invalid entry in code metrics conf
|
||||
dotnet_diagnostic.ca1861.severity = none # Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)
|
||||
|
||||
dotnet_diagnostic.cs8618.severity = suggestion # nullable problem
|
||||
dotnet_diagnostic.CS0809.severity = suggestion # obsolete errors
|
||||
dotnet_diagnostic.CS0618.severity = suggestion # obsolete errors
|
||||
|
||||
|
||||
# Performance rules
|
||||
|
||||
@@ -12,10 +12,17 @@ public static class ElementIdHelper
|
||||
|
||||
public static ElementId? GetElementId(string elementId)
|
||||
{
|
||||
#if REVIT2024_OR_GREATER
|
||||
if (long.TryParse(elementId, out long elementIdInt))
|
||||
{
|
||||
return new ElementId(elementIdInt);
|
||||
}
|
||||
#else
|
||||
if (int.TryParse(elementId, out int elementIdInt))
|
||||
{
|
||||
return new ElementId(elementIdInt);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
<Configurations>Debug;Release;Local</Configurations>
|
||||
<RhinoVersion>8</RhinoVersion>
|
||||
<DefineConstants>$(DefineConstants);RHINO8;RHINO7_OR_GREATER;RHIN08_OR_GREATER</DefineConstants>
|
||||
<DefineConstants>$(DefineConstants);RHINO8;RHINO7_OR_GREATER;RHINO8_OR_GREATER</DefineConstants>
|
||||
<TargetExt>.rhp</TargetExt>
|
||||
<StartProgram>$(ProgramFiles)\Rhino $(RhinoVersion)\System\Rhino.exe</StartProgram>
|
||||
<EnableWindowsTargeting>true</EnableWindowsTargeting>
|
||||
|
||||
@@ -16,6 +16,13 @@ public class RhinoLayerBaker : TraversalContextUnpacker
|
||||
private readonly RhinoColorBaker _colorBaker;
|
||||
private readonly Dictionary<string, int> _hostLayerCache = new();
|
||||
|
||||
private static readonly string s_pathSeparator =
|
||||
#if RHINO8_OR_GREATER
|
||||
ModelComponent.NamePathSeparator;
|
||||
#else
|
||||
Layer.PathSeparator;
|
||||
#endif
|
||||
|
||||
public RhinoLayerBaker(RhinoMaterialBaker materialBaker, RhinoColorBaker colorBaker)
|
||||
{
|
||||
_materialBaker = materialBaker;
|
||||
@@ -68,7 +75,7 @@ public class RhinoLayerBaker : TraversalContextUnpacker
|
||||
.Select(o => string.IsNullOrWhiteSpace(o.name) ? "unnamed" : o.name)
|
||||
.Prepend(baseLayerName);
|
||||
|
||||
var layerFullName = string.Join(Layer.PathSeparator, layerPath);
|
||||
var layerFullName = string.Join(s_pathSeparator, layerPath);
|
||||
|
||||
if (_hostLayerCache.TryGetValue(layerFullName, out int existingLayerIndex))
|
||||
{
|
||||
@@ -91,7 +98,7 @@ public class RhinoLayerBaker : TraversalContextUnpacker
|
||||
Layer? previousLayer = currentDocument.Layers.FindName(currentLayerName);
|
||||
foreach (Collection collection in collectionPath)
|
||||
{
|
||||
currentLayerName += Layer.PathSeparator + collection.name;
|
||||
currentLayerName += s_pathSeparator + collection.name;
|
||||
currentLayerName = currentLayerName.Replace("{", "").Replace("}", ""); // Rhino specific cleanup for gh (see RemoveInvalidRhinoChars)
|
||||
if (_hostLayerCache.TryGetValue(currentLayerName, out int value))
|
||||
{
|
||||
|
||||
@@ -2,6 +2,9 @@ using Rhino;
|
||||
using Speckle.Sdk.Models.Collections;
|
||||
using Layer = Rhino.DocObjects.Layer;
|
||||
using SpeckleLayer = Speckle.Sdk.Models.Collections.Layer;
|
||||
#if RHINO8_OR_GREATER
|
||||
using Rhino.DocObjects;
|
||||
#endif
|
||||
|
||||
namespace Speckle.Connectors.Rhino.HostApp;
|
||||
|
||||
@@ -12,6 +15,14 @@ public class RhinoLayerUnpacker
|
||||
{
|
||||
private readonly Dictionary<int, Collection> _layerCollectionCache = new();
|
||||
|
||||
private static readonly string s_pathSeparator =
|
||||
#if RHINO8_OR_GREATER
|
||||
ModelComponent.NamePathSeparator;
|
||||
#else
|
||||
Layer.PathSeparator;
|
||||
#endif
|
||||
private static readonly string[] s_pathSeparatorSplit = [s_pathSeparator];
|
||||
|
||||
/// <summary>
|
||||
/// <para>Use this method to construct the root commit object while converting objects.</para>
|
||||
/// <para>Returns the host collection corresponding to the provided layer. If it's the first time that it is being asked for, it will be created and stored in the root object collection.</para>
|
||||
@@ -26,7 +37,7 @@ public class RhinoLayerUnpacker
|
||||
return value;
|
||||
}
|
||||
|
||||
var names = layer.FullPath.Split(new[] { Layer.PathSeparator }, StringSplitOptions.None);
|
||||
var names = layer.FullPath.Split(s_pathSeparatorSplit, StringSplitOptions.None);
|
||||
var path = names[0];
|
||||
var index = 0;
|
||||
var previousCollection = rootObjectCollection;
|
||||
@@ -53,7 +64,7 @@ public class RhinoLayerUnpacker
|
||||
|
||||
if (index < names.Length - 1)
|
||||
{
|
||||
path += Layer.PathSeparator + names[index + 1];
|
||||
path += s_pathSeparator + names[index + 1];
|
||||
}
|
||||
|
||||
index++;
|
||||
|
||||
@@ -45,8 +45,13 @@ public sealed class CorridorHandler
|
||||
List<Base> baselines = new(corridor.Baselines.Count);
|
||||
foreach (CDB.Baseline baseline in corridor.Baselines)
|
||||
{
|
||||
#if CIVIL3D2025_OR_GREATER
|
||||
string baselineGuid = baseline.BaselineGuid.ToString();
|
||||
#else
|
||||
string baselineGuid = baseline.baselineGUID.ToString();
|
||||
|
||||
#endif
|
||||
|
||||
Base convertedBaseline =
|
||||
new()
|
||||
{
|
||||
|
||||
+3
-1
@@ -174,7 +174,9 @@ public class ClassPropertiesExtractor
|
||||
["innerHeight"] = pipe.InnerHeight,
|
||||
["slope"] = pipe.Slope,
|
||||
["shape"] = pipe.CrossSectionalShape.ToString(),
|
||||
["length2d"] = pipe.Length2D,
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
["length2d"] = pipe.Length2D, //Length2D was un-obsoleted in 2023, but is still marked obsolete in 2022
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
["minimumCover"] = pipe.MinimumCover,
|
||||
["maximumCover"] = pipe.MaximumCover,
|
||||
["junctionLoss"] = pipe.JunctionLoss,
|
||||
|
||||
@@ -26,7 +26,11 @@ public static class CategoryExtensions
|
||||
|
||||
public static BuiltInCategory GetBuiltInCategory(this Category category)
|
||||
{
|
||||
#if REVIT2024_OR_GREATER
|
||||
return (BuiltInCategory)category.Id.Value;
|
||||
#else
|
||||
return (BuiltInCategory)category.Id.IntegerValue;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static string GetBuiltInFromSchemaBuilderCategory(this SOBR.RevitCategory c)
|
||||
|
||||
@@ -29,7 +29,11 @@ public class RevitCategoryInfo
|
||||
|
||||
public bool ContainsRevitCategory(Category category)
|
||||
{
|
||||
#if REVIT2024_OR_GREATER
|
||||
return BuiltInCategories.Select(x => (long)x).Contains(category.Id.Value);
|
||||
#else
|
||||
return BuiltInCategories.Select(x => (int)x).Contains(category.Id.IntegerValue);
|
||||
#endif
|
||||
}
|
||||
|
||||
public List<ElementType> GetElementTypes(Document document)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
<Configurations>Debug;Release;Local</Configurations>
|
||||
<DefineConstants>$(DefineConstants);RHINO8;RHINO7_OR_GREATER;RHIN08_OR_GREATER</DefineConstants>
|
||||
<DefineConstants>$(DefineConstants);RHINO8;RHINO7_OR_GREATER;RHINO8_OR_GREATER</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user