From e5c7023a8d33568d9e72880218a7cc6077f39b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20L=2E=20Kiss?= <50739844+jozseflkiss@users.noreply.github.com> Date: Thu, 9 Nov 2023 18:33:28 +0100 Subject: [PATCH] fix(archicad): Archicad nullable levels fix (#3032) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * archicad level is null * Fixing braces & throw Coding standards now ask for {} around single code blocks after If and other areas where single line is acceptable. Also the if in this case does not need to have an else, as it can just throw if the IF is not entered. --------- Co-authored-by: JoĢzsef L. Kiss <> Co-authored-by: Ian Hawley --- Objects/Objects/BuiltElements/Beam.cs | 8 +++++--- Objects/Objects/BuiltElements/Column.cs | 8 +++++--- Objects/Objects/BuiltElements/Floor.cs | 8 +++++--- Objects/Objects/BuiltElements/Roof.cs | 8 +++++--- Objects/Objects/BuiltElements/Wall.cs | 8 +++++--- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Objects/Objects/BuiltElements/Beam.cs b/Objects/Objects/BuiltElements/Beam.cs index 8931a6de34..0f4396ed88 100644 --- a/Objects/Objects/BuiltElements/Beam.cs +++ b/Objects/Objects/BuiltElements/Beam.cs @@ -141,10 +141,12 @@ public override Level? level get => archicadLevel; internal set { - if (value is not ArchicadLevel l) - throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}"); + if (value is ArchicadLevel or null) + { + archicadLevel = value as ArchicadLevel; + } - archicadLevel = l; + throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}"); } } diff --git a/Objects/Objects/BuiltElements/Column.cs b/Objects/Objects/BuiltElements/Column.cs index db62a85988..b0ef02c697 100644 --- a/Objects/Objects/BuiltElements/Column.cs +++ b/Objects/Objects/BuiltElements/Column.cs @@ -167,10 +167,12 @@ public override Level? level get => archicadLevel; internal set { - if (value is not ArchicadLevel l) - throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}"); + if (value is ArchicadLevel or null) + { + archicadLevel = value as ArchicadLevel; + } - archicadLevel = l; + throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}"); } } diff --git a/Objects/Objects/BuiltElements/Floor.cs b/Objects/Objects/BuiltElements/Floor.cs index d83e0f071d..3fcdf4c837 100644 --- a/Objects/Objects/BuiltElements/Floor.cs +++ b/Objects/Objects/BuiltElements/Floor.cs @@ -103,10 +103,12 @@ public override Level? level get => archicadLevel; internal set { - if (value is not ArchicadLevel l) - throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}"); + if (value is ArchicadLevel or null) + { + archicadLevel = value as ArchicadLevel; + } - archicadLevel = l; + throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}"); } } diff --git a/Objects/Objects/BuiltElements/Roof.cs b/Objects/Objects/BuiltElements/Roof.cs index 1683354b7e..02979d3766 100644 --- a/Objects/Objects/BuiltElements/Roof.cs +++ b/Objects/Objects/BuiltElements/Roof.cs @@ -153,10 +153,12 @@ public override Level? level get => archicadLevel; internal set { - if (value is not ArchicadLevel l) - throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}"); + if (value is ArchicadLevel or null) + { + archicadLevel = value as ArchicadLevel; + } - archicadLevel = l; + throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}"); } } diff --git a/Objects/Objects/BuiltElements/Wall.cs b/Objects/Objects/BuiltElements/Wall.cs index 051c69294c..a5dd9d358b 100644 --- a/Objects/Objects/BuiltElements/Wall.cs +++ b/Objects/Objects/BuiltElements/Wall.cs @@ -308,10 +308,12 @@ public override Level? level get => archicadLevel; internal set { - if (value is not ArchicadLevel l) - throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}"); + if (value is ArchicadLevel or null) + { + archicadLevel = value as ArchicadLevel; + } - archicadLevel = l; + throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}"); } }