diff --git a/.editorconfig b/.editorconfig index a133ead38..32ff38613 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 diff --git a/Connectors/Revit/Speckle.Connectors.RevitShared/ElementIdHelper.cs b/Connectors/Revit/Speckle.Connectors.RevitShared/ElementIdHelper.cs index fdbe913a2..8501cae2d 100644 --- a/Connectors/Revit/Speckle.Connectors.RevitShared/ElementIdHelper.cs +++ b/Connectors/Revit/Speckle.Connectors.RevitShared/ElementIdHelper.cs @@ -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; diff --git a/Connectors/Rhino/Speckle.Connectors.Rhino8/Speckle.Connectors.Rhino8.csproj b/Connectors/Rhino/Speckle.Connectors.Rhino8/Speckle.Connectors.Rhino8.csproj index 55680b7f4..c3880e351 100644 --- a/Connectors/Rhino/Speckle.Connectors.Rhino8/Speckle.Connectors.Rhino8.csproj +++ b/Connectors/Rhino/Speckle.Connectors.Rhino8/Speckle.Connectors.Rhino8.csproj @@ -3,7 +3,7 @@ net48 Debug;Release;Local 8 - $(DefineConstants);RHINO8;RHINO7_OR_GREATER;RHIN08_OR_GREATER + $(DefineConstants);RHINO8;RHINO7_OR_GREATER;RHINO8_OR_GREATER .rhp $(ProgramFiles)\Rhino $(RhinoVersion)\System\Rhino.exe true diff --git a/Connectors/Rhino/Speckle.Connectors.RhinoShared/HostApp/RhinoLayerBaker.cs b/Connectors/Rhino/Speckle.Connectors.RhinoShared/HostApp/RhinoLayerBaker.cs index 95aa94fd0..4814cd531 100644 --- a/Connectors/Rhino/Speckle.Connectors.RhinoShared/HostApp/RhinoLayerBaker.cs +++ b/Connectors/Rhino/Speckle.Connectors.RhinoShared/HostApp/RhinoLayerBaker.cs @@ -16,6 +16,13 @@ public class RhinoLayerBaker : TraversalContextUnpacker private readonly RhinoColorBaker _colorBaker; private readonly Dictionary _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 int GetLayerIndex(Collection[] collectionPath, string baseLayerName) .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 @@ private int CreateLayerFromPath(Collection[] collectionPath, string baseLayerNam 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)) { diff --git a/Connectors/Rhino/Speckle.Connectors.RhinoShared/HostApp/RhinoLayerUnpacker.cs b/Connectors/Rhino/Speckle.Connectors.RhinoShared/HostApp/RhinoLayerUnpacker.cs index 229eaf779..cf8e05d2e 100644 --- a/Connectors/Rhino/Speckle.Connectors.RhinoShared/HostApp/RhinoLayerUnpacker.cs +++ b/Connectors/Rhino/Speckle.Connectors.RhinoShared/HostApp/RhinoLayerUnpacker.cs @@ -2,6 +2,9 @@ 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 _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]; + /// /// Use this method to construct the root commit object while converting objects. /// 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. @@ -26,7 +37,7 @@ public Collection GetHostObjectCollection(Layer layer, Collection rootObjectColl 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 Collection GetHostObjectCollection(Layer layer, Collection rootObjectColl if (index < names.Length - 1) { - path += Layer.PathSeparator + names[index + 1]; + path += s_pathSeparator + names[index + 1]; } index++; diff --git a/Converters/Civil3d/Speckle.Converters.Civil3dShared/Helpers/CorridorHandler.cs b/Converters/Civil3d/Speckle.Converters.Civil3dShared/Helpers/CorridorHandler.cs index 0e35e13ce..371f614b4 100644 --- a/Converters/Civil3d/Speckle.Converters.Civil3dShared/Helpers/CorridorHandler.cs +++ b/Converters/Civil3d/Speckle.Converters.Civil3dShared/Helpers/CorridorHandler.cs @@ -45,8 +45,13 @@ public List GetCorridorChildren(CDB.Corridor corridor) List 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() { diff --git a/Converters/Civil3d/Speckle.Converters.Civil3dShared/ToSpeckle/Properties/ClassPropertiesExtractor.cs b/Converters/Civil3d/Speckle.Converters.Civil3dShared/ToSpeckle/Properties/ClassPropertiesExtractor.cs index 8fd6d7052..82407ab78 100644 --- a/Converters/Civil3d/Speckle.Converters.Civil3dShared/ToSpeckle/Properties/ClassPropertiesExtractor.cs +++ b/Converters/Civil3d/Speckle.Converters.Civil3dShared/ToSpeckle/Properties/ClassPropertiesExtractor.cs @@ -174,7 +174,9 @@ PipeNetworkHandler pipeNetworkHandler ["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, diff --git a/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs b/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs index 3ade4816e..15b388dc7 100644 --- a/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs +++ b/Converters/Revit/Speckle.Converters.RevitShared/Extensions/CategoryExtensions.cs @@ -26,7 +26,11 @@ public static SOBR.RevitCategory GetSchemaBuilderCategoryFromBuiltIn(this DB.Bui 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) diff --git a/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs b/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs index f883f7c9e..08c58e37d 100644 --- a/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs +++ b/Converters/Revit/Speckle.Converters.RevitShared/Helpers/RevitCategoryInfo.cs @@ -29,7 +29,11 @@ public 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 GetElementTypes(Document document) diff --git a/Converters/Rhino/Speckle.Converters.Rhino8/Speckle.Converters.Rhino8.csproj b/Converters/Rhino/Speckle.Converters.Rhino8/Speckle.Converters.Rhino8.csproj index 9109a4b8a..22ea3ed42 100644 --- a/Converters/Rhino/Speckle.Converters.Rhino8/Speckle.Converters.Rhino8.csproj +++ b/Converters/Rhino/Speckle.Converters.Rhino8/Speckle.Converters.Rhino8.csproj @@ -3,7 +3,7 @@ net48 Debug;Release;Local - $(DefineConstants);RHINO8;RHINO7_OR_GREATER;RHIN08_OR_GREATER + $(DefineConstants);RHINO8;RHINO7_OR_GREATER;RHINO8_OR_GREATER