From 0af76100765b223b3bc1eb8f873606eea6eaf267 Mon Sep 17 00:00:00 2001 From: Viet Le Date: Fri, 30 Oct 2026 10:01:06 +0000 Subject: [PATCH 1/5] Update Beam.py --- src/bhom_schema/FixtureAlpha_oM/Beam.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bhom_schema/FixtureAlpha_oM/Beam.py b/src/bhom_schema/FixtureAlpha_oM/Beam.py index a3e5ded..32a0793 100644 --- a/src/bhom_schema/FixtureAlpha_oM/Beam.py +++ b/src/bhom_schema/FixtureAlpha_oM/Beam.py @@ -31,3 +31,4 @@ class Beam(BHoMObject): Start: PointLike | None = None Count: Annotated[int, ClrType('long')] = 3 Small: Annotated[float, ClrType('float')] = 0.5 + Material: str = Field(default='Steel', description='Name of the material.') From 7425fa90ef8b42aeec617cbc915ab269e77d06ec Mon Sep 17 00:00:00 2001 From: Viet Le Date: Fri, 30 Oct 2026 10:47:45 +0000 Subject: [PATCH 2/5] Localise C# test classes --- .../AdministrativeInformation/ProjectLike.cs | 33 + .../Fixtures/FixtureAlpha_oM/Enums/Enums.cs | 44 + .../FixtureAlpha_oM/FixtureAlpha_oM.csproj | 34 + .../FixtureAlpha_oM/Geometry/Geometry.cs | 44 + .../Fixtures/FixtureAlpha_oM/Hardening.cs | 68 ++ .../FixtureAlpha_oM/Interfaces/Interfaces.cs | 41 + .../Fixtures/FixtureAlpha_oM/Objects.cs | 109 +++ .../FixtureBeta_oM/FixtureBeta_oM.csproj | 29 + .../csharp/Fixtures/FixtureBeta_oM/Objects.cs | 41 + .../DocumentationTests.cs | 2 +- .../GoldenAndWorkflowTests.cs | 43 +- .../PythonSchemaGeneration.Tests.csproj | 13 +- .../fixtures/FixtureAlpha_oM/Collections.py | 35 - .../golden/fixtures/FixtureAlpha_oM/CycleB.py | 28 - .../FixtureAlpha_oM/GeometryHolder.py | 28 - .../fixtures/FixtureAlpha_oM/GridHolder.py | 26 - .../FixtureAlpha_oM/IElement1DLike.py | 22 - .../fixtures/FixtureAlpha_oM/IGeometryLike.py | 23 - .../fixtures/FixtureAlpha_oM/ILabelled.py | 23 - .../FixtureAlpha_oM/IOpeningLike_1.py | 20 - .../fixtures/FixtureAlpha_oM/IPanelLike_2.py | 21 - .../fixtures/FixtureAlpha_oM/LineLike.py | 31 - .../fixtures/FixtureAlpha_oM/PointLike.py | 25 - .../fixtures/FixtureAlpha_oM/ProjectLike.py | 26 - .../fixtures/FixtureAlpha_oM/Scalars.py | 40 - .../golden/fixtures/FixtureAlpha_oM/Sparse.py | 22 - .../fixtures/FixtureAlpha_oM/SparseHolder.py | 23 - .../fixtures/FixtureAlpha_oM/SparseParent.py | 23 - .../fixtures/FixtureAlpha_oM/ThingIdentity.py | 22 - .../fixtures/FixtureAlpha_oM/TreeLike_1.py | 26 - .../FixtureBeta_oM/Elements/UsesBoth.py | 25 - .ci/unit-tests/golden/fixtures/manifest.json | 884 ------------------ .../python/test_py2cs/test_documentation.py | 2 +- .ci/unit-tests/run-all.ps1 | 4 - .github/workflows/pr-checks.yml | 2 - .gitignore | 2 + README.md | 4 +- docs/CODING-PLAN.md | 4 +- docs/Testing-Guide.md | 8 +- docs/Testing-On-GitHub.md | 4 +- 40 files changed, 460 insertions(+), 1444 deletions(-) create mode 100644 .ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/AdministrativeInformation/ProjectLike.cs create mode 100644 .ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Enums/Enums.cs create mode 100644 .ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/FixtureAlpha_oM.csproj create mode 100644 .ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Geometry/Geometry.cs create mode 100644 .ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Hardening.cs create mode 100644 .ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Interfaces/Interfaces.cs create mode 100644 .ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Objects.cs create mode 100644 .ci/unit-tests/csharp/Fixtures/FixtureBeta_oM/FixtureBeta_oM.csproj create mode 100644 .ci/unit-tests/csharp/Fixtures/FixtureBeta_oM/Objects.cs delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/Collections.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/CycleB.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/GeometryHolder.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/GridHolder.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/IElement1DLike.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/IGeometryLike.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/ILabelled.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/IOpeningLike_1.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/IPanelLike_2.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/LineLike.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/PointLike.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/ProjectLike.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/Scalars.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/Sparse.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/SparseHolder.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/SparseParent.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/ThingIdentity.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureAlpha_oM/TreeLike_1.py delete mode 100644 .ci/unit-tests/golden/fixtures/FixtureBeta_oM/Elements/UsesBoth.py delete mode 100644 .ci/unit-tests/golden/fixtures/manifest.json diff --git a/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/AdministrativeInformation/ProjectLike.cs b/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/AdministrativeInformation/ProjectLike.cs new file mode 100644 index 0000000..8ec0959 --- /dev/null +++ b/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/AdministrativeInformation/ProjectLike.cs @@ -0,0 +1,33 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2025, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +namespace BH.oM.FixtureAlpha +{ + //File folder differs from the namespace on purpose, like dKoP_oM/AdministrativeInformation/ProjectIdentification.cs + public class ProjectLike : ThingIdentity + { + public virtual string ProjectReference { get; set; } = ""; + public virtual string ProjectName { get; set; } = ""; + public virtual string ProjectLocation { get; set; } = ""; + public virtual string AdditionalReferences { get; set; } = ""; + } +} diff --git a/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Enums/Enums.cs b/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Enums/Enums.cs new file mode 100644 index 0000000..8f7d38f --- /dev/null +++ b/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Enums/Enums.cs @@ -0,0 +1,44 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2025, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using System; +using System.ComponentModel; + +namespace BH.oM.FixtureAlpha +{ + [Description("Kinds of support.")] + public enum SupportKind + { + None, + [Description("Fully fixed.")] + Fixed, + Pinned + } + + [Flags] + public enum Options + { + A = 1, + B = 2, + Both = 3 + } +} diff --git a/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/FixtureAlpha_oM.csproj b/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/FixtureAlpha_oM.csproj new file mode 100644 index 0000000..eaa3154 --- /dev/null +++ b/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/FixtureAlpha_oM.csproj @@ -0,0 +1,34 @@ + + + + netstandard2.0 + 10.0.0.0 + https://github.com/BHoM/CSharpSchema_Test + 1.0.0 + BHoM + Copyright © https://github.com/BHoM + BH.oM.FixtureAlpha + 10.0.0.0 + latest + disable + + + + + $(ProgramData)\BHoM\Assemblies\BHoM.dll + false + false + + + $(ProgramData)\BHoM\Assemblies\Quantities_oM.dll + false + false + + + + + + + + + diff --git a/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Geometry/Geometry.cs b/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Geometry/Geometry.cs new file mode 100644 index 0000000..70c7436 --- /dev/null +++ b/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Geometry/Geometry.cs @@ -0,0 +1,44 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2025, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using System.ComponentModel; +using BH.oM.Base; + +namespace BH.oM.FixtureAlpha +{ + public class PointLike : IGeometryLike + { + public virtual double X { get; set; } = 0; + public virtual double Y { get; set; } = 0; + public virtual double Z { get; set; } = 0; + } + + [Description("A straight segment between two points.")] + public class LineLike : ICurveLike, ILabelled + { + public virtual PointLike Start { get; set; } = new PointLike(); + public virtual PointLike End { get; set; } = new PointLike(); + [Description("Extends the line to infinity.")] + public virtual bool Infinite { get; set; } = false; + public virtual string Label { get; set; } = null; + } +} diff --git a/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Hardening.cs b/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Hardening.cs new file mode 100644 index 0000000..d506eef --- /dev/null +++ b/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Hardening.cs @@ -0,0 +1,68 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2025, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using System.Collections.Generic; +using System.Collections.ObjectModel; +using BH.oM.Base; + +namespace BH.oM.FixtureAlpha +{ + //No member has the value 0, but the C# default of a property of this type is 0 + public enum Sparse + { + One = 1, + Two = 2, + } + + public class SparseHolder : BHoMObject + { + public virtual Sparse Level { get; set; } + } + + //Its default instance cannot be created in Python, because SparseHolder needs an argument + public class SparseParent : BHoMObject + { + public virtual SparseHolder Holder { get; set; } = new SparseHolder(); + } + + //A generic class that names itself in a default collection + public class TreeLike : BHoMObject + { + public virtual Dictionary> Children { get; set; } = new Dictionary>(); + public virtual List Values { get; set; } = new List(); + } + + public class GridHolder : BHoMObject + { + public virtual double[,] Matrix { get; set; } = new double[2, 2]; + public virtual ReadOnlyDictionary Table { get; set; } = new ReadOnlyDictionary(new Dictionary()); + } + + public interface IOpeningLike : IBHoMObject + { + } + + //A constraint that depends on another type parameter + public interface IPanelLike : IBHoMObject where TOpening : IOpeningLike + { + } +} diff --git a/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Interfaces/Interfaces.cs b/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Interfaces/Interfaces.cs new file mode 100644 index 0000000..97d0372 --- /dev/null +++ b/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Interfaces/Interfaces.cs @@ -0,0 +1,41 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2025, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using BH.oM.Base; + +namespace BH.oM.FixtureAlpha +{ + public interface IGeometryLike : IObject { } + + public interface IElement1DLike : IObject { } + + //Two parent interfaces, like ICurve : IGeometry, IElement1D + public interface ICurveLike : IGeometryLike, IElement1DLike { } + + //No "I" prefix on purpose, like IdKoPObject + public interface ThingIdentity : IObject { } + + public interface ILabelled : IObject + { + string Label { get; set; } + } +} diff --git a/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Objects.cs b/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Objects.cs new file mode 100644 index 0000000..6002253 --- /dev/null +++ b/.ci/unit-tests/csharp/Fixtures/FixtureAlpha_oM/Objects.cs @@ -0,0 +1,109 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2025, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using BH.oM.Base; +using BH.oM.Base.Attributes; +using BH.oM.Quantities.Attributes; + +namespace BH.oM.FixtureAlpha +{ + //Immutable: no parameterless constructor, so every field is required, on top of the defaulted BHoMObject fields + public class ImmutableThing : BHoMObject, IImmutable + { + public virtual string Id { get; } + public virtual double Length { get; } + + public ImmutableThing(string id, double length) + { + Id = id; + Length = length; + } + } + + public class Wrapper : BHoMObject where T : IBHoMObject + { + public virtual List Items { get; set; } = new List(); + } + + public class Beam : BHoMObject + { + [Length] + [DisplayText("Span length")] + [Description("Distance between the supports.")] + public virtual double Span { get; set; } = 1.5; + + public virtual SupportKind Support { get; set; } = SupportKind.Pinned; + public virtual Options Flags { get; set; } = Options.A; + public virtual PointLike Start { get; set; } = null; + public virtual long Count { get; set; } = 3; + public virtual float Small { get; set; } = 0.5f; + } + + public class Collections : BHoMObject + { + public virtual HashSet Names { get; set; } = new HashSet(); + public virtual HashSet Points { get; set; } = new HashSet(); + public virtual Dictionary Lookup { get; set; } = new Dictionary(); + public virtual Dictionary ByPoint { get; set; } = new Dictionary(); + public virtual double[] Values { get; set; } = new double[0]; + public virtual List> Matrix { get; set; } = new List>(); + public virtual IEnumerable Words { get; set; } = new List { "a", "b" }; + public virtual int? OptionalCount { get; set; } = null; + public virtual Tuple Pair { get; set; } = null; + public virtual object Anything { get; set; } = null; + } + + public class Scalars : BHoMObject + { + public virtual DateTime Created { get; set; } = DateTime.Now; + public virtual DateTime Fixed { get; set; } = new DateTime(2020, 1, 2, 3, 4, 5); + public virtual Guid Key { get; set; } = Guid.Empty; + public virtual decimal Cost { get; set; } = 1.5m; + public virtual Color Colour { get; set; } = Color.Empty; + public virtual TimeSpan Duration { get; set; } = TimeSpan.FromSeconds(90); + public virtual char Letter { get; set; } = 'x'; + public virtual string Quote { get; set; } = "it's \"here\""; + public virtual Type TypeRef { get; set; } = null; + public virtual Func Callback { get; set; } = null; + public virtual double Big { get; set; } = double.MaxValue; + } + + public class GeometryHolder : BHoMObject + { + public virtual IGeometryLike Geometry { get; set; } = null; + public virtual List Curves { get; set; } = new List(); + } + + public class CycleA : IObject + { + public virtual CycleB Other { get; set; } = null; + } + + public class CycleB : IObject + { + public virtual CycleA Other { get; set; } = null; + } +} diff --git a/.ci/unit-tests/csharp/Fixtures/FixtureBeta_oM/FixtureBeta_oM.csproj b/.ci/unit-tests/csharp/Fixtures/FixtureBeta_oM/FixtureBeta_oM.csproj new file mode 100644 index 0000000..f1c0ace --- /dev/null +++ b/.ci/unit-tests/csharp/Fixtures/FixtureBeta_oM/FixtureBeta_oM.csproj @@ -0,0 +1,29 @@ + + + + netstandard2.0 + 10.0.0.0 + https://github.com/BHoM/CSharpSchema_Test + 1.0.0 + BHoM + Copyright © https://github.com/BHoM + BH.oM.FixtureBeta + 10.0.0.0 + latest + disable + + + + + $(ProgramData)\BHoM\Assemblies\BHoM.dll + false + false + + + + + + + + + diff --git a/.ci/unit-tests/csharp/Fixtures/FixtureBeta_oM/Objects.cs b/.ci/unit-tests/csharp/Fixtures/FixtureBeta_oM/Objects.cs new file mode 100644 index 0000000..13500c3 --- /dev/null +++ b/.ci/unit-tests/csharp/Fixtures/FixtureBeta_oM/Objects.cs @@ -0,0 +1,41 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2025, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using BH.oM.Base; + +namespace BH.oM.FixtureBeta +{ + //Same simple name as FixtureAlpha.PointLike, in another assembly + public class PointLike : IObject + { + public virtual double X { get; set; } = 0; + } +} + +namespace BH.oM.FixtureBeta.Elements +{ + public class UsesBoth : BHoMObject + { + public virtual FixtureAlpha.PointLike FromAlpha { get; set; } = null; + public virtual PointLike Local { get; set; } = null; + } +} diff --git a/.ci/unit-tests/csharp/PythonSchemaGeneration.Tests/DocumentationTests.cs b/.ci/unit-tests/csharp/PythonSchemaGeneration.Tests/DocumentationTests.cs index 6e3aea9..749d9fb 100644 --- a/.ci/unit-tests/csharp/PythonSchemaGeneration.Tests/DocumentationTests.cs +++ b/.ci/unit-tests/csharp/PythonSchemaGeneration.Tests/DocumentationTests.cs @@ -8,7 +8,7 @@ public class DocumentationTests { /***************************************************/ - private static readonly string[] m_Skipped = { "obj", "bin", ".vs", "_output", "TestResults", "golden" }; + private static readonly string[] m_Skipped = { "obj", "bin", ".vs", "_output", "TestResults", "golden", "Fixtures" }; /***************************************************/ diff --git a/.ci/unit-tests/csharp/PythonSchemaGeneration.Tests/GoldenAndWorkflowTests.cs b/.ci/unit-tests/csharp/PythonSchemaGeneration.Tests/GoldenAndWorkflowTests.cs index edc6d9f..d17e04c 100644 --- a/.ci/unit-tests/csharp/PythonSchemaGeneration.Tests/GoldenAndWorkflowTests.cs +++ b/.ci/unit-tests/csharp/PythonSchemaGeneration.Tests/GoldenAndWorkflowTests.cs @@ -1,7 +1,4 @@ using System.Text; -using System.Text.Encodings.Web; -using System.Text.Json; -using System.Text.Json.Nodes; using PythonSchemaGeneration; using PythonSchemaGeneration.Emission; @@ -28,36 +25,16 @@ public static void Matches(string goldenFolder, string relativePath, string actu public class GoldenTests { - //One fixture class per situation the generator must handle. Classes added to the fixture repository later are not compared, so a merged - //C# change does not break these tests; add a class here only when it covers a situation that no listed class covers. + //One fixture class per output shape of the generator. Keep it short: add a class only for a shape that no listed class shows. private static readonly string[] m_PinnedClasses = { "FixtureAlpha_oM/Beam", - "FixtureAlpha_oM/Collections", "FixtureAlpha_oM/CycleA", - "FixtureAlpha_oM/CycleB", - "FixtureAlpha_oM/GeometryHolder", - "FixtureAlpha_oM/GridHolder", "FixtureAlpha_oM/ICurveLike", - "FixtureAlpha_oM/IElement1DLike", - "FixtureAlpha_oM/IGeometryLike", - "FixtureAlpha_oM/ILabelled", - "FixtureAlpha_oM/IOpeningLike_1", - "FixtureAlpha_oM/IPanelLike_2", "FixtureAlpha_oM/ImmutableThing", - "FixtureAlpha_oM/LineLike", "FixtureAlpha_oM/Options", - "FixtureAlpha_oM/PointLike", - "FixtureAlpha_oM/ProjectLike", - "FixtureAlpha_oM/Scalars", - "FixtureAlpha_oM/Sparse", - "FixtureAlpha_oM/SparseHolder", - "FixtureAlpha_oM/SparseParent", "FixtureAlpha_oM/SupportKind", - "FixtureAlpha_oM/ThingIdentity", - "FixtureAlpha_oM/TreeLike_1", "FixtureAlpha_oM/Wrapper_1", - "FixtureBeta_oM/Elements/UsesBoth", "FixtureBeta_oM/PointLike" }; @@ -74,24 +51,6 @@ public void FixtureOutputMatchesGoldenFiles() foreach (RenderedType type in pinned) GoldenAssert.Matches("fixtures", type.Ref.RelativePath + ".py", type.Text); } - - /***************************************************/ - - [Test] - [Description("Checks that the entries of the pinned fixture classes in the manifest written for the fixture run are identical to the committed golden manifest. " + - "Protects the language-neutral manifest that py2cs and alignment read.")] - public void FixtureManifestMatchesGolden() - { - JsonNode manifest = JsonNode.Parse(File.ReadAllText(Path.Combine(FixtureOutput.Folder, "manifest.json"))); - JsonArray types = manifest["types"].AsArray(); - List kept = types.Where(t => m_PinnedClasses.Contains(((string)t["relativePath"]).Replace(".py", ""))).ToList(); - types.Clear(); - foreach (JsonNode type in kept) - types.Add(type.DeepClone()); - - string text = manifest.ToJsonString(new JsonSerializerOptions { WriteIndented = true, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping }) + '\n'; - GoldenAssert.Matches("fixtures", "manifest.json", text); - } } public class WorkflowTests diff --git a/.ci/unit-tests/csharp/PythonSchemaGeneration.Tests/PythonSchemaGeneration.Tests.csproj b/.ci/unit-tests/csharp/PythonSchemaGeneration.Tests/PythonSchemaGeneration.Tests.csproj index 47c7ab6..0578458 100644 --- a/.ci/unit-tests/csharp/PythonSchemaGeneration.Tests/PythonSchemaGeneration.Tests.csproj +++ b/.ci/unit-tests/csharp/PythonSchemaGeneration.Tests/PythonSchemaGeneration.Tests.csproj @@ -2,11 +2,6 @@ - - $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', '..', '..', '..', '..', '..', 'CSharpSchema_Test')) - $([MSBuild]::EnsureTrailingSlash('$(CSharpSchemaTestRoot)')) - - net8.0 enable @@ -30,14 +25,10 @@ - - + + - - - - diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/Collections.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/Collections.py deleted file mode 100644 index 7fd68fa..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/Collections.py +++ /dev/null @@ -1,35 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.Collections. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. -# pyright: reportUnknownVariableType=false, reportIncompatibleVariableOverride=false - -from __future__ import annotations - -from typing import Annotated, Any, ClassVar - -from pydantic import Field - -from bhom_schema.BHoM.BHoMObject import BHoMObject -from bhom_schema.FixtureAlpha_oM.PointLike import PointLike -from bhom_schema._support import ClrType - - -class Collections(BHoMObject): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.Collections', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'class', - } - - Names: set[str] = Field(default_factory=set) - Points: Annotated[list[PointLike], ClrType('System.Collections.Generic.HashSet')] = Field(default_factory=list) - Lookup: dict[str, float] = Field(default_factory=dict) - ByPoint: Annotated[list[tuple[PointLike, str]], ClrType('System.Collections.Generic.Dictionary')] = Field(default_factory=list) - Values: Annotated[list[float], ClrType('double[]')] = Field(default_factory=list) - Matrix: list[list[int]] = Field(default_factory=list) - Words: Annotated[list[str], ClrType('System.Collections.Generic.IEnumerable')] = Field(default_factory=lambda: ['a', 'b']) - OptionalCount: int | None = None - Pair: tuple[int, str] | None = None - Anything: Any | None = None diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/CycleB.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/CycleB.py deleted file mode 100644 index e865cb2..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/CycleB.py +++ /dev/null @@ -1,28 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.CycleB. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. -# pyright: reportUnknownVariableType=false, reportIncompatibleVariableOverride=false - -from __future__ import annotations - -from typing import Any, ClassVar - -from bhom_schema.BHoM.IObject import IObject -from bhom_schema._support import SchemaModel - - -class CycleB(SchemaModel, IObject): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.CycleB', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'class', - } - - Other: CycleA | None = None - - -from bhom_schema.FixtureAlpha_oM.CycleA import CycleA - -CycleB.model_rebuild() diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/GeometryHolder.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/GeometryHolder.py deleted file mode 100644 index 9a82c51..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/GeometryHolder.py +++ /dev/null @@ -1,28 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.GeometryHolder. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. -# pyright: reportUnknownVariableType=false, reportIncompatibleVariableOverride=false - -from __future__ import annotations - -from typing import Any, ClassVar - -from pydantic import Field - -from bhom_schema.BHoM.BHoMObject import BHoMObject -from bhom_schema.FixtureAlpha_oM.ICurveLike import ICurveLike -from bhom_schema.FixtureAlpha_oM.IGeometryLike import IGeometryLike -from bhom_schema._support import Polymorphic - - -class GeometryHolder(BHoMObject): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.GeometryHolder', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'class', - } - - Geometry: Polymorphic[IGeometryLike] | None = None - Curves: list[Polymorphic[ICurveLike]] = Field(default_factory=list) diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/GridHolder.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/GridHolder.py deleted file mode 100644 index 1f17f28..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/GridHolder.py +++ /dev/null @@ -1,26 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.GridHolder. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. -# pyright: reportUnknownVariableType=false, reportIncompatibleVariableOverride=false - -from __future__ import annotations - -from typing import Annotated, Any, ClassVar - -from pydantic import Field - -from bhom_schema.BHoM.BHoMObject import BHoMObject -from bhom_schema._support import ClrType - - -class GridHolder(BHoMObject): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.GridHolder', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'class', - } - - Matrix: Annotated[list[list[float]], ClrType('double[,]')] = Field(default_factory=lambda: [[0.0, 0.0], [0.0, 0.0]]) - Table: Annotated[dict[str, float], ClrType('System.Collections.ObjectModel.ReadOnlyDictionary')] = Field(default_factory=dict) diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/IElement1DLike.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/IElement1DLike.py deleted file mode 100644 index 548d77b..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/IElement1DLike.py +++ /dev/null @@ -1,22 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.IElement1DLike. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. - -from __future__ import annotations - -from typing import Any, ClassVar - -from bhom_schema.BHoM.IObject import IObject - - -class IElement1DLike(IObject): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.IElement1DLike', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'interface', - 'implementers': { - 'BH.oM.FixtureAlpha.LineLike': 'FixtureAlpha_oM.LineLike', - }, - } diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/IGeometryLike.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/IGeometryLike.py deleted file mode 100644 index e469e36..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/IGeometryLike.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.IGeometryLike. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. - -from __future__ import annotations - -from typing import Any, ClassVar - -from bhom_schema.BHoM.IObject import IObject - - -class IGeometryLike(IObject): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.IGeometryLike', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'interface', - 'implementers': { - 'BH.oM.FixtureAlpha.LineLike': 'FixtureAlpha_oM.LineLike', - 'BH.oM.FixtureAlpha.PointLike': 'FixtureAlpha_oM.PointLike', - }, - } diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/ILabelled.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/ILabelled.py deleted file mode 100644 index f2b664e..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/ILabelled.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.ILabelled. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. - -from __future__ import annotations - -from typing import Any, ClassVar - -from bhom_schema.BHoM.IObject import IObject - - -class ILabelled(IObject): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.ILabelled', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'interface', - 'properties': {'Label': {'type': 'string'}}, - 'implementers': { - 'BH.oM.FixtureAlpha.LineLike': 'FixtureAlpha_oM.LineLike', - }, - } diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/IOpeningLike_1.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/IOpeningLike_1.py deleted file mode 100644 index 7dcc986..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/IOpeningLike_1.py +++ /dev/null @@ -1,20 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.IOpeningLike`1. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. - -from __future__ import annotations - -from typing import Any, ClassVar - -from bhom_schema.BHoM.IBHoMObject import IBHoMObject - - -class IOpeningLike_1[T](IBHoMObject): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.IOpeningLike`1', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'interface', - 'generic_params': {'T': []}, - } diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/IPanelLike_2.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/IPanelLike_2.py deleted file mode 100644 index 0d23c7d..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/IPanelLike_2.py +++ /dev/null @@ -1,21 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.IPanelLike`2. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. - -from __future__ import annotations - -from typing import Any, ClassVar - -from bhom_schema.BHoM.IBHoMObject import IBHoMObject -from bhom_schema.FixtureAlpha_oM.IOpeningLike_1 import IOpeningLike_1 - - -class IPanelLike_2[TEdge, TOpening: IOpeningLike_1[Any]](IBHoMObject): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.IPanelLike`2', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'interface', - 'generic_params': {'TEdge': [], 'TOpening': ['BH.oM.FixtureAlpha.IOpeningLike']}, - } diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/LineLike.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/LineLike.py deleted file mode 100644 index 4f419f7..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/LineLike.py +++ /dev/null @@ -1,31 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.LineLike. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. -# pyright: reportUnknownVariableType=false, reportIncompatibleVariableOverride=false - -from __future__ import annotations - -from typing import Any, ClassVar - -from pydantic import Field - -from bhom_schema.FixtureAlpha_oM.ICurveLike import ICurveLike -from bhom_schema.FixtureAlpha_oM.ILabelled import ILabelled -from bhom_schema.FixtureAlpha_oM.PointLike import PointLike -from bhom_schema._support import SchemaModel - - -class LineLike(SchemaModel, ICurveLike, ILabelled): - """A straight segment between two points.""" - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.LineLike', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'class', - } - - Start: PointLike = Field(default_factory=lambda: PointLike()) - End: PointLike = Field(default_factory=lambda: PointLike()) - Infinite: bool = Field(default=False, description='Extends the line to infinity.') - Label: str | None = None diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/PointLike.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/PointLike.py deleted file mode 100644 index efd3266..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/PointLike.py +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.PointLike. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. -# pyright: reportUnknownVariableType=false, reportIncompatibleVariableOverride=false - -from __future__ import annotations - -from typing import Any, ClassVar - -from bhom_schema.FixtureAlpha_oM.IGeometryLike import IGeometryLike -from bhom_schema._support import SchemaModel - - -class PointLike(SchemaModel, IGeometryLike): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.PointLike', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'class', - } - - X: float = 0.0 - Y: float = 0.0 - Z: float = 0.0 diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/ProjectLike.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/ProjectLike.py deleted file mode 100644 index ac1f3dd..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/ProjectLike.py +++ /dev/null @@ -1,26 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.ProjectLike. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. -# pyright: reportUnknownVariableType=false, reportIncompatibleVariableOverride=false - -from __future__ import annotations - -from typing import Any, ClassVar - -from bhom_schema.FixtureAlpha_oM.ThingIdentity import ThingIdentity -from bhom_schema._support import SchemaModel - - -class ProjectLike(SchemaModel, ThingIdentity): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.ProjectLike', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'class', - } - - ProjectReference: str = '' - ProjectName: str = '' - ProjectLocation: str = '' - AdditionalReferences: str = '' diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/Scalars.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/Scalars.py deleted file mode 100644 index 42612a2..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/Scalars.py +++ /dev/null @@ -1,40 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.Scalars. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. -# pyright: reportUnknownVariableType=false, reportIncompatibleVariableOverride=false - -from __future__ import annotations - -from collections.abc import Callable -from datetime import datetime, timedelta -from decimal import Decimal -from typing import Annotated, Any, ClassVar -from uuid import UUID - -from pydantic import Field -from pydantic.json_schema import SkipJsonSchema - -from bhom_schema.BHoM.BHoMObject import BHoMObject -from bhom_schema._support import ClrType, Color - - -class Scalars(BHoMObject): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.Scalars', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'class', - } - - Created: datetime = Field(default_factory=datetime.now) - Fixed: datetime = datetime(2020, 1, 2, 3, 4, 5, 0) - Key: UUID = UUID(int=0) - Cost: Decimal = Decimal('1.5') - Colour: Color = Field(default_factory=Color) - Duration: timedelta = timedelta(seconds=90.0) - Letter: Annotated[str, ClrType('char')] = 'x' - Quote: str = 'it\'s "here"' - TypeRef: Annotated[Any | None, ClrType('System.Type')] = None - Callback: Annotated[SkipJsonSchema[Callable[..., Any]] | None, ClrType('System.Func')] = None - Big: float = 1.7976931348623157e+308 diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/Sparse.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/Sparse.py deleted file mode 100644 index d2d6b36..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/Sparse.py +++ /dev/null @@ -1,22 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.Sparse. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. - -from __future__ import annotations - -from typing import Any, ClassVar - -from bhom_schema._support import BHoMEnum - - -class Sparse(BHoMEnum): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.Sparse', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'enum', - } - - One = 1 - Two = 2 diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/SparseHolder.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/SparseHolder.py deleted file mode 100644 index 211da26..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/SparseHolder.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.SparseHolder. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. -# pyright: reportUnknownVariableType=false, reportIncompatibleVariableOverride=false - -from __future__ import annotations - -from typing import Any, ClassVar - -from bhom_schema.BHoM.BHoMObject import BHoMObject -from bhom_schema.FixtureAlpha_oM.Sparse import Sparse - - -class SparseHolder(BHoMObject): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.SparseHolder', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'class', - } - - Level: Sparse diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/SparseParent.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/SparseParent.py deleted file mode 100644 index a510c0e..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/SparseParent.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.SparseParent. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. -# pyright: reportUnknownVariableType=false, reportIncompatibleVariableOverride=false - -from __future__ import annotations - -from typing import Any, ClassVar - -from bhom_schema.BHoM.BHoMObject import BHoMObject -from bhom_schema.FixtureAlpha_oM.SparseHolder import SparseHolder - - -class SparseParent(BHoMObject): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.SparseParent', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'class', - } - - Holder: SparseHolder diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/ThingIdentity.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/ThingIdentity.py deleted file mode 100644 index 861dd35..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/ThingIdentity.py +++ /dev/null @@ -1,22 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.ThingIdentity. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. - -from __future__ import annotations - -from typing import Any, ClassVar - -from bhom_schema.BHoM.IObject import IObject - - -class ThingIdentity(IObject): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.ThingIdentity', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'interface', - 'implementers': { - 'BH.oM.FixtureAlpha.ProjectLike': 'FixtureAlpha_oM.ProjectLike', - }, - } diff --git a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/TreeLike_1.py b/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/TreeLike_1.py deleted file mode 100644 index 19b9aa3..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureAlpha_oM/TreeLike_1.py +++ /dev/null @@ -1,26 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureAlpha.TreeLike`1. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. -# pyright: reportUnknownVariableType=false, reportIncompatibleVariableOverride=false - -from __future__ import annotations - -from typing import Any, ClassVar - -from pydantic import Field - -from bhom_schema.BHoM.BHoMObject import BHoMObject - - -class TreeLike_1[T](BHoMObject): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureAlpha.TreeLike`1', - 'assembly': 'FixtureAlpha_oM', - 'namespace': 'BH.oM.FixtureAlpha', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'class', - 'generic_params': {'T': []}, - } - - Children: dict[str, TreeLike_1[T]] = Field(default_factory=lambda: {}) - Values: list[T] = Field(default_factory=lambda: []) diff --git a/.ci/unit-tests/golden/fixtures/FixtureBeta_oM/Elements/UsesBoth.py b/.ci/unit-tests/golden/fixtures/FixtureBeta_oM/Elements/UsesBoth.py deleted file mode 100644 index 26e0d9b..0000000 --- a/.ci/unit-tests/golden/fixtures/FixtureBeta_oM/Elements/UsesBoth.py +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by BHoM_PythonSchema from the C# oM type BH.oM.FixtureBeta.Elements.UsesBoth. Do not edit by hand. -# Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. -# Licensed under the GNU Lesser General Public License, version 3.0 or later. -# pyright: reportUnknownVariableType=false, reportIncompatibleVariableOverride=false - -from __future__ import annotations - -from typing import Any, ClassVar - -from bhom_schema.BHoM.BHoMObject import BHoMObject -from bhom_schema.FixtureAlpha_oM.PointLike import PointLike -from bhom_schema.FixtureBeta_oM.PointLike import PointLike as FixtureBeta_oM_PointLike - - -class UsesBoth(BHoMObject): - __bhom__: ClassVar[dict[str, Any]] = { - 'clr_name': 'BH.oM.FixtureBeta.Elements.UsesBoth', - 'assembly': 'FixtureBeta_oM', - 'namespace': 'BH.oM.FixtureBeta.Elements', - 'repo': 'BHoM/CSharpSchema_Test', - 'kind': 'class', - } - - FromAlpha: PointLike | None = None - Local: FixtureBeta_oM_PointLike | None = None diff --git a/.ci/unit-tests/golden/fixtures/manifest.json b/.ci/unit-tests/golden/fixtures/manifest.json deleted file mode 100644 index aaa52de..0000000 --- a/.ci/unit-tests/golden/fixtures/manifest.json +++ /dev/null @@ -1,884 +0,0 @@ -{ - "schemaVersion": 1, - "types": [ - { - "clrName": "BH.oM.FixtureAlpha.Beam", - "name": "BH.oM.FixtureAlpha.Beam", - "pythonName": "Beam", - "pythonModule": "bhom_schema.FixtureAlpha_oM.Beam", - "relativePath": "FixtureAlpha_oM/Beam.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "class", - "bases": [ - "BH.oM.Base.BHoMObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [ - { - "name": "Span", - "clrType": "double", - "pyName": "Span", - "hasDefault": true, - "default": "1.5", - "description": "Distance between the supports.", - "quantity": { - "category": "Length", - "unit": "m" - }, - "displayText": "Span length" - }, - { - "name": "Support", - "clrType": "BH.oM.FixtureAlpha.SupportKind", - "pyName": "Support", - "hasDefault": true, - "default": "SupportKind.Pinned" - }, - { - "name": "Flags", - "clrType": "BH.oM.FixtureAlpha.Options", - "pyName": "Flags", - "hasDefault": true, - "default": "Options.A" - }, - { - "name": "Start", - "clrType": "BH.oM.FixtureAlpha.PointLike", - "pyName": "Start", - "hasDefault": true, - "default": "None" - }, - { - "name": "Count", - "clrType": "long", - "pyName": "Count", - "hasDefault": true, - "default": "3" - }, - { - "name": "Small", - "clrType": "float", - "pyName": "Small", - "hasDefault": true, - "default": "0.5" - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.Collections", - "name": "BH.oM.FixtureAlpha.Collections", - "pythonName": "Collections", - "pythonModule": "bhom_schema.FixtureAlpha_oM.Collections", - "relativePath": "FixtureAlpha_oM/Collections.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "class", - "bases": [ - "BH.oM.Base.BHoMObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [ - { - "name": "Names", - "clrType": "System.Collections.Generic.HashSet", - "pyName": "Names", - "hasDefault": true, - "default": " set" - }, - { - "name": "Points", - "clrType": "System.Collections.Generic.HashSet", - "pyName": "Points", - "hasDefault": true, - "default": " list" - }, - { - "name": "Lookup", - "clrType": "System.Collections.Generic.Dictionary", - "pyName": "Lookup", - "hasDefault": true, - "default": " dict" - }, - { - "name": "ByPoint", - "clrType": "System.Collections.Generic.Dictionary", - "pyName": "ByPoint", - "hasDefault": true, - "default": " list" - }, - { - "name": "Values", - "clrType": "double[]", - "pyName": "Values", - "hasDefault": true, - "default": " list" - }, - { - "name": "Matrix", - "clrType": "System.Collections.Generic.List>", - "pyName": "Matrix", - "hasDefault": true, - "default": " list" - }, - { - "name": "Words", - "clrType": "System.Collections.Generic.IEnumerable", - "pyName": "Words", - "hasDefault": true, - "default": " lambda: ['a', 'b']" - }, - { - "name": "OptionalCount", - "clrType": "int?", - "pyName": "OptionalCount", - "hasDefault": true, - "default": "None" - }, - { - "name": "Pair", - "clrType": "System.Tuple", - "pyName": "Pair", - "hasDefault": true, - "default": "None" - }, - { - "name": "Anything", - "clrType": "object", - "pyName": "Anything", - "hasDefault": true, - "default": "None" - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.CycleA", - "name": "BH.oM.FixtureAlpha.CycleA", - "pythonName": "CycleA", - "pythonModule": "bhom_schema.FixtureAlpha_oM.CycleA", - "relativePath": "FixtureAlpha_oM/CycleA.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "class", - "bases": [ - "BH.oM.Base.IObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [ - { - "name": "Other", - "clrType": "BH.oM.FixtureAlpha.CycleB", - "pyName": "Other", - "hasDefault": true, - "default": "None" - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.CycleB", - "name": "BH.oM.FixtureAlpha.CycleB", - "pythonName": "CycleB", - "pythonModule": "bhom_schema.FixtureAlpha_oM.CycleB", - "relativePath": "FixtureAlpha_oM/CycleB.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "class", - "bases": [ - "BH.oM.Base.IObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [ - { - "name": "Other", - "clrType": "BH.oM.FixtureAlpha.CycleA", - "pyName": "Other", - "hasDefault": true, - "default": "None" - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.GeometryHolder", - "name": "BH.oM.FixtureAlpha.GeometryHolder", - "pythonName": "GeometryHolder", - "pythonModule": "bhom_schema.FixtureAlpha_oM.GeometryHolder", - "relativePath": "FixtureAlpha_oM/GeometryHolder.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "class", - "bases": [ - "BH.oM.Base.BHoMObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [ - { - "name": "Geometry", - "clrType": "BH.oM.FixtureAlpha.IGeometryLike", - "pyName": "Geometry", - "hasDefault": true, - "default": "None" - }, - { - "name": "Curves", - "clrType": "System.Collections.Generic.List", - "pyName": "Curves", - "hasDefault": true, - "default": " list" - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.GridHolder", - "name": "BH.oM.FixtureAlpha.GridHolder", - "pythonName": "GridHolder", - "pythonModule": "bhom_schema.FixtureAlpha_oM.GridHolder", - "relativePath": "FixtureAlpha_oM/GridHolder.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "class", - "bases": [ - "BH.oM.Base.BHoMObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [ - { - "name": "Matrix", - "clrType": "double[,]", - "pyName": "Matrix", - "hasDefault": true, - "default": " lambda: [[0.0, 0.0], [0.0, 0.0]]" - }, - { - "name": "Table", - "clrType": "System.Collections.ObjectModel.ReadOnlyDictionary", - "pyName": "Table", - "hasDefault": true, - "default": " dict" - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.ICurveLike", - "name": "BH.oM.FixtureAlpha.ICurveLike", - "pythonName": "ICurveLike", - "pythonModule": "bhom_schema.FixtureAlpha_oM.ICurveLike", - "relativePath": "FixtureAlpha_oM/ICurveLike.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "interface", - "bases": [ - "BH.oM.FixtureAlpha.IElement1DLike", - "BH.oM.FixtureAlpha.IGeometryLike" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [] - }, - { - "clrName": "BH.oM.FixtureAlpha.IElement1DLike", - "name": "BH.oM.FixtureAlpha.IElement1DLike", - "pythonName": "IElement1DLike", - "pythonModule": "bhom_schema.FixtureAlpha_oM.IElement1DLike", - "relativePath": "FixtureAlpha_oM/IElement1DLike.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "interface", - "bases": [ - "BH.oM.Base.IObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [] - }, - { - "clrName": "BH.oM.FixtureAlpha.IGeometryLike", - "name": "BH.oM.FixtureAlpha.IGeometryLike", - "pythonName": "IGeometryLike", - "pythonModule": "bhom_schema.FixtureAlpha_oM.IGeometryLike", - "relativePath": "FixtureAlpha_oM/IGeometryLike.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "interface", - "bases": [ - "BH.oM.Base.IObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [] - }, - { - "clrName": "BH.oM.FixtureAlpha.ILabelled", - "name": "BH.oM.FixtureAlpha.ILabelled", - "pythonName": "ILabelled", - "pythonModule": "bhom_schema.FixtureAlpha_oM.ILabelled", - "relativePath": "FixtureAlpha_oM/ILabelled.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "interface", - "bases": [ - "BH.oM.Base.IObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [ - { - "name": "Label", - "clrType": "string" - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.IOpeningLike`1", - "name": "BH.oM.FixtureAlpha.IOpeningLike", - "pythonName": "IOpeningLike_1", - "pythonModule": "bhom_schema.FixtureAlpha_oM.IOpeningLike_1", - "relativePath": "FixtureAlpha_oM/IOpeningLike_1.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "interface", - "bases": [ - "BH.oM.Base.IBHoMObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "genericParams": [ - { - "name": "T", - "constraints": [] - } - ], - "properties": [] - }, - { - "clrName": "BH.oM.FixtureAlpha.IPanelLike`2", - "name": "BH.oM.FixtureAlpha.IPanelLike", - "pythonName": "IPanelLike_2", - "pythonModule": "bhom_schema.FixtureAlpha_oM.IPanelLike_2", - "relativePath": "FixtureAlpha_oM/IPanelLike_2.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "interface", - "bases": [ - "BH.oM.Base.IBHoMObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "genericParams": [ - { - "name": "TEdge", - "constraints": [] - }, - { - "name": "TOpening", - "constraints": [ - "BH.oM.FixtureAlpha.IOpeningLike" - ] - } - ], - "properties": [] - }, - { - "clrName": "BH.oM.FixtureAlpha.ImmutableThing", - "name": "BH.oM.FixtureAlpha.ImmutableThing", - "pythonName": "ImmutableThing", - "pythonModule": "bhom_schema.FixtureAlpha_oM.ImmutableThing", - "relativePath": "FixtureAlpha_oM/ImmutableThing.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "class", - "bases": [ - "BH.oM.Base.BHoMObject", - "BH.oM.Base.IImmutable" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [ - { - "name": "Id", - "clrType": "string", - "pyName": "Id", - "hasDefault": false - }, - { - "name": "Length", - "clrType": "double", - "pyName": "Length", - "hasDefault": false - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.LineLike", - "name": "BH.oM.FixtureAlpha.LineLike", - "pythonName": "LineLike", - "pythonModule": "bhom_schema.FixtureAlpha_oM.LineLike", - "relativePath": "FixtureAlpha_oM/LineLike.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "class", - "bases": [ - "BH.oM.FixtureAlpha.ICurveLike", - "BH.oM.FixtureAlpha.ILabelled" - ], - "repo": "BHoM/CSharpSchema_Test", - "description": "A straight segment between two points.", - "properties": [ - { - "name": "Start", - "clrType": "BH.oM.FixtureAlpha.PointLike", - "pyName": "Start", - "hasDefault": true, - "default": " lambda: PointLike()" - }, - { - "name": "End", - "clrType": "BH.oM.FixtureAlpha.PointLike", - "pyName": "End", - "hasDefault": true, - "default": " lambda: PointLike()" - }, - { - "name": "Infinite", - "clrType": "bool", - "pyName": "Infinite", - "hasDefault": true, - "default": "False", - "description": "Extends the line to infinity." - }, - { - "name": "Label", - "clrType": "string", - "pyName": "Label", - "hasDefault": true, - "default": "None" - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.Options", - "name": "BH.oM.FixtureAlpha.Options", - "pythonName": "Options", - "pythonModule": "bhom_schema.FixtureAlpha_oM.Options", - "relativePath": "FixtureAlpha_oM/Options.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "enum", - "bases": [], - "repo": "BHoM/CSharpSchema_Test", - "flags": true, - "properties": [], - "members": [ - { - "name": "A", - "value": "1" - }, - { - "name": "B", - "value": "2" - }, - { - "name": "Both", - "value": "3" - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.PointLike", - "name": "BH.oM.FixtureAlpha.PointLike", - "pythonName": "PointLike", - "pythonModule": "bhom_schema.FixtureAlpha_oM.PointLike", - "relativePath": "FixtureAlpha_oM/PointLike.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "class", - "bases": [ - "BH.oM.FixtureAlpha.IGeometryLike" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [ - { - "name": "X", - "clrType": "double", - "pyName": "X", - "hasDefault": true, - "default": "0.0" - }, - { - "name": "Y", - "clrType": "double", - "pyName": "Y", - "hasDefault": true, - "default": "0.0" - }, - { - "name": "Z", - "clrType": "double", - "pyName": "Z", - "hasDefault": true, - "default": "0.0" - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.ProjectLike", - "name": "BH.oM.FixtureAlpha.ProjectLike", - "pythonName": "ProjectLike", - "pythonModule": "bhom_schema.FixtureAlpha_oM.ProjectLike", - "relativePath": "FixtureAlpha_oM/ProjectLike.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "class", - "bases": [ - "BH.oM.FixtureAlpha.ThingIdentity" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [ - { - "name": "ProjectReference", - "clrType": "string", - "pyName": "ProjectReference", - "hasDefault": true, - "default": "''" - }, - { - "name": "ProjectName", - "clrType": "string", - "pyName": "ProjectName", - "hasDefault": true, - "default": "''" - }, - { - "name": "ProjectLocation", - "clrType": "string", - "pyName": "ProjectLocation", - "hasDefault": true, - "default": "''" - }, - { - "name": "AdditionalReferences", - "clrType": "string", - "pyName": "AdditionalReferences", - "hasDefault": true, - "default": "''" - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.Scalars", - "name": "BH.oM.FixtureAlpha.Scalars", - "pythonName": "Scalars", - "pythonModule": "bhom_schema.FixtureAlpha_oM.Scalars", - "relativePath": "FixtureAlpha_oM/Scalars.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "class", - "bases": [ - "BH.oM.Base.BHoMObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [ - { - "name": "Created", - "clrType": "System.DateTime", - "pyName": "Created", - "hasDefault": true, - "default": " datetime.now" - }, - { - "name": "Fixed", - "clrType": "System.DateTime", - "pyName": "Fixed", - "hasDefault": true, - "default": "datetime(2020, 1, 2, 3, 4, 5, 0)" - }, - { - "name": "Key", - "clrType": "System.Guid", - "pyName": "Key", - "hasDefault": true, - "default": "UUID(int=0)" - }, - { - "name": "Cost", - "clrType": "decimal", - "pyName": "Cost", - "hasDefault": true, - "default": "Decimal('1.5')" - }, - { - "name": "Colour", - "clrType": "System.Drawing.Color", - "pyName": "Colour", - "hasDefault": true, - "default": " Color" - }, - { - "name": "Duration", - "clrType": "System.TimeSpan", - "pyName": "Duration", - "hasDefault": true, - "default": "timedelta(seconds=90.0)" - }, - { - "name": "Letter", - "clrType": "char", - "pyName": "Letter", - "hasDefault": true, - "default": "'x'" - }, - { - "name": "Quote", - "clrType": "string", - "pyName": "Quote", - "hasDefault": true, - "default": "'it\\'s \"here\"'" - }, - { - "name": "TypeRef", - "clrType": "System.Type", - "pyName": "TypeRef", - "hasDefault": true, - "default": "None" - }, - { - "name": "Callback", - "clrType": "System.Func", - "pyName": "Callback", - "hasDefault": true, - "default": "None" - }, - { - "name": "Big", - "clrType": "double", - "pyName": "Big", - "hasDefault": true, - "default": "1.7976931348623157e+308" - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.Sparse", - "name": "BH.oM.FixtureAlpha.Sparse", - "pythonName": "Sparse", - "pythonModule": "bhom_schema.FixtureAlpha_oM.Sparse", - "relativePath": "FixtureAlpha_oM/Sparse.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "enum", - "bases": [], - "repo": "BHoM/CSharpSchema_Test", - "properties": [], - "members": [ - { - "name": "One", - "value": "1" - }, - { - "name": "Two", - "value": "2" - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.SparseHolder", - "name": "BH.oM.FixtureAlpha.SparseHolder", - "pythonName": "SparseHolder", - "pythonModule": "bhom_schema.FixtureAlpha_oM.SparseHolder", - "relativePath": "FixtureAlpha_oM/SparseHolder.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "class", - "bases": [ - "BH.oM.Base.BHoMObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [ - { - "name": "Level", - "clrType": "BH.oM.FixtureAlpha.Sparse", - "pyName": "Level", - "hasDefault": false - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.SparseParent", - "name": "BH.oM.FixtureAlpha.SparseParent", - "pythonName": "SparseParent", - "pythonModule": "bhom_schema.FixtureAlpha_oM.SparseParent", - "relativePath": "FixtureAlpha_oM/SparseParent.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "class", - "bases": [ - "BH.oM.Base.BHoMObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [ - { - "name": "Holder", - "clrType": "BH.oM.FixtureAlpha.SparseHolder", - "pyName": "Holder", - "hasDefault": false - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.SupportKind", - "name": "BH.oM.FixtureAlpha.SupportKind", - "pythonName": "SupportKind", - "pythonModule": "bhom_schema.FixtureAlpha_oM.SupportKind", - "relativePath": "FixtureAlpha_oM/SupportKind.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "enum", - "bases": [], - "repo": "BHoM/CSharpSchema_Test", - "description": "Kinds of support.", - "properties": [], - "members": [ - { - "name": "None", - "value": "0" - }, - { - "name": "Fixed", - "value": "1", - "description": "Fully fixed." - }, - { - "name": "Pinned", - "value": "2" - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.ThingIdentity", - "name": "BH.oM.FixtureAlpha.ThingIdentity", - "pythonName": "ThingIdentity", - "pythonModule": "bhom_schema.FixtureAlpha_oM.ThingIdentity", - "relativePath": "FixtureAlpha_oM/ThingIdentity.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "interface", - "bases": [ - "BH.oM.Base.IObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [] - }, - { - "clrName": "BH.oM.FixtureAlpha.TreeLike`1", - "name": "BH.oM.FixtureAlpha.TreeLike", - "pythonName": "TreeLike_1", - "pythonModule": "bhom_schema.FixtureAlpha_oM.TreeLike_1", - "relativePath": "FixtureAlpha_oM/TreeLike_1.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "class", - "bases": [ - "BH.oM.Base.BHoMObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "genericParams": [ - { - "name": "T", - "constraints": [] - } - ], - "properties": [ - { - "name": "Children", - "clrType": "System.Collections.Generic.Dictionary>", - "pyName": "Children", - "hasDefault": true, - "default": " lambda: {}" - }, - { - "name": "Values", - "clrType": "System.Collections.Generic.List", - "pyName": "Values", - "hasDefault": true, - "default": " lambda: []" - } - ] - }, - { - "clrName": "BH.oM.FixtureAlpha.Wrapper`1", - "name": "BH.oM.FixtureAlpha.Wrapper", - "pythonName": "Wrapper_1", - "pythonModule": "bhom_schema.FixtureAlpha_oM.Wrapper_1", - "relativePath": "FixtureAlpha_oM/Wrapper_1.py", - "namespace": "BH.oM.FixtureAlpha", - "assembly": "FixtureAlpha_oM", - "kind": "class", - "bases": [ - "BH.oM.Base.BHoMObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "genericParams": [ - { - "name": "T", - "constraints": [ - "BH.oM.Base.IBHoMObject" - ] - } - ], - "properties": [ - { - "name": "Items", - "clrType": "System.Collections.Generic.List", - "pyName": "Items", - "hasDefault": true, - "default": " lambda: []" - } - ] - }, - { - "clrName": "BH.oM.FixtureBeta.Elements.UsesBoth", - "name": "BH.oM.FixtureBeta.Elements.UsesBoth", - "pythonName": "UsesBoth", - "pythonModule": "bhom_schema.FixtureBeta_oM.Elements.UsesBoth", - "relativePath": "FixtureBeta_oM/Elements/UsesBoth.py", - "namespace": "BH.oM.FixtureBeta.Elements", - "assembly": "FixtureBeta_oM", - "kind": "class", - "bases": [ - "BH.oM.Base.BHoMObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [ - { - "name": "FromAlpha", - "clrType": "BH.oM.FixtureAlpha.PointLike", - "pyName": "FromAlpha", - "hasDefault": true, - "default": "None" - }, - { - "name": "Local", - "clrType": "BH.oM.FixtureBeta.PointLike", - "pyName": "Local", - "hasDefault": true, - "default": "None" - } - ] - }, - { - "clrName": "BH.oM.FixtureBeta.PointLike", - "name": "BH.oM.FixtureBeta.PointLike", - "pythonName": "PointLike", - "pythonModule": "bhom_schema.FixtureBeta_oM.PointLike", - "relativePath": "FixtureBeta_oM/PointLike.py", - "namespace": "BH.oM.FixtureBeta", - "assembly": "FixtureBeta_oM", - "kind": "class", - "bases": [ - "BH.oM.Base.IObject" - ], - "repo": "BHoM/CSharpSchema_Test", - "properties": [ - { - "name": "X", - "clrType": "double", - "pyName": "X", - "hasDefault": true, - "default": "0.0" - } - ] - } - ] -} diff --git a/.ci/unit-tests/python/test_py2cs/test_documentation.py b/.ci/unit-tests/python/test_py2cs/test_documentation.py index e4f5a23..85d0a26 100644 --- a/.ci/unit-tests/python/test_py2cs/test_documentation.py +++ b/.ci/unit-tests/python/test_py2cs/test_documentation.py @@ -7,7 +7,7 @@ REPO = Path(__file__).resolve().parents[4] FOLDERS = [REPO / ".ci", REPO / "src"] -SKIPPED = {"_output", ".venv", "__pycache__", "bin", "obj", ".vs", "TestResults", "golden"} +SKIPPED = {"_output", ".venv", "__pycache__", "bin", "obj", ".vs", "TestResults", "golden", "Fixtures"} def python_files() -> list[Path]: """Finds the Python files of the repository that are written by hand or by the converters' own tools.""" diff --git a/.ci/unit-tests/run-all.ps1 b/.ci/unit-tests/run-all.ps1 index 8d2a1a4..e398088 100644 --- a/.ci/unit-tests/run-all.ps1 +++ b/.ci/unit-tests/run-all.ps1 @@ -34,10 +34,6 @@ if ($missing) { } else { Write-Host "All $($required.Count) required assemblies are installed." } -$testClasses = if ($env:CSharpSchemaTestRoot) { $env:CSharpSchemaTestRoot } else { Join-Path (Split-Path $root -Parent) "CSharpSchema_Test" } -if (-not (Test-Path (Join-Path $testClasses "FixtureAlpha_oM\FixtureAlpha_oM.csproj"))) { - throw "The test classes were not found at $testClasses. Clone https://github.com/BHoM/CSharpSchema_Test next to this repository, or set the CSharpSchemaTestRoot environment variable." -} if (-not (Test-Path $python)) { throw "No virtual environment: run python -m venv .venv ; .venv\Scripts\python -m pip install -e '.[dev]'" } $env:PYTHONPATH = Join-Path $root ".ci\generation" diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 4e9897c..5a50d0c 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -19,8 +19,6 @@ jobs: # Real-type tests fail instead of being skipped when an assembly is missing CI: 'true' PYTHONPATH: ${{ github.workspace }}/.ci/generation - # The test classes are cloned into .repos, not next to this repository - CSharpSchemaTestRoot: ${{ github.workspace }}\.repos\CSharpSchema_Test\ BHOM_JSONSCHEMA_ROOT: ${{ github.workspace }}\.repos\BHoM_JSONSchema steps: diff --git a/.gitignore b/.gitignore index 53234de..7157884 100644 --- a/.gitignore +++ b/.gitignore @@ -78,3 +78,5 @@ dist/ .ci/unit-tests/_output/ .ci/unit-tests/**/TestResults/ /.claude +# Read-only clones made by the scripts +.repos/ diff --git a/README.md b/README.md index 29d5b66..5ac5023 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ Python (Pydantic) classes generated from the BHoM C# object model (oM), the Pyth ## Development setup -Prerequisites: .NET 8 SDK, Python 3.12, a clone of [CSharpSchema_Test](https://github.com/BHoM/CSharpSchema_Test) next to this repository (the C# classes the tests use), and the BHoM assemblies installed in `%ProgramData%\BHoM\Assemblies` -(build the repositories in `Included-repositories.txt`: `BHoM`, `BHoM_Engine`, `JSONSchema_Toolkit` and `CSharpSchema_Test`). +Prerequisites: .NET 8 SDK, Python 3.12, and the BHoM assemblies installed in `%ProgramData%\BHoM\Assemblies` +(build the repositories in `Included-repositories.txt`: `BHoM`, `BHoM_Engine`, `JSONSchema_Toolkit` and `CSharpSchema_Test`). The generator tests use their own small test classes in `.ci/unit-tests/csharp/Fixtures`, so they need no other repository. ```powershell python -m venv .venv diff --git a/docs/CODING-PLAN.md b/docs/CODING-PLAN.md index 34e6180..9cad8bd 100644 --- a/docs/CODING-PLAN.md +++ b/docs/CODING-PLAN.md @@ -9,7 +9,7 @@ taken so far (section 9). ## Implementation status (phases 0 to 6 done, 7 and 8 not started) -Run `.ci/unit-tests/run-all.ps1`; it builds, generates, drafts, round-trips, runs NUnit (93 tests), pytest (195 tests) and Pyright. +Run `.ci/unit-tests/run-all.ps1`; it builds, generates, drafts, round-trips, runs NUnit (92 tests), pytest (195 tests) and Pyright. Where the implementation differs from the plan above: @@ -69,7 +69,7 @@ BHoM_PythonSchema/ │ └─ unit-tests/ │ ├─ csharp/ │ │ ├─ PythonSchemaGeneration.Tests/ NUnit tests -│ │ └─ (FixtureAlpha_oM, FixtureBeta_oM: moved to the CSharpSchema_Test repository, cloned next to this one) +│ │ └─ Fixtures/ (FixtureAlpha_oM, FixtureBeta_oM: the generator's test classes) │ ├─ python/ pytest tests (converters, PR raiser, generated package) │ ├─ golden/ hand-written expected .py / .cs / report outputs │ ├─ github-fixtures/ recorded repository listings and API replies for offline tests diff --git a/docs/Testing-Guide.md b/docs/Testing-Guide.md index eb434aa..e822777 100644 --- a/docs/Testing-Guide.md +++ b/docs/Testing-Guide.md @@ -32,7 +32,7 @@ So the C# tests are not only checks; they **produce the input** the Python tests |---|---| | `run-all.ps1` | Runs every stage in the right order. Use this unless you are working on one part. | | `csharp/PythonSchemaGeneration.Tests/` | The NUnit tests (44 tests). | -| (not in this repository) | The fake oM assemblies `FixtureAlpha_oM` and `FixtureBeta_oM` live in the [CSharpSchema_Test](https://github.com/BHoM/CSharpSchema_Test) repository, which must be cloned next to this one (or set `CSharpSchemaTestRoot`). See section 3. | +| `csharp/Fixtures/` | The fake oM assemblies `FixtureAlpha_oM` and `FixtureBeta_oM`: the test classes of the generator, in this repository. They started as a copy of [CSharpSchema_Test](https://github.com/BHoM/CSharpSchema_Test) and are separate from it: that repository is where the loop is rehearsed, and changes there never reach these tests. Their assembly `Description` names CSharpSchema_Test on purpose, because the generator reads the owning repository from it. See section 3. | | `python/` | The pytest tests (about 73 test cases) in four folders: `test_py2cs`, `test_fixtures`, `test_spike`, `test_alignment`. | | `python/support.py` | Shared helpers for the pytest folders. | | `golden/` | Committed "expected output" files. See section 6. | @@ -43,7 +43,7 @@ So the C# tests are not only checks; they **produce the input** the Python tests | Tier | Input | Needs | Where | |---|---|---|---| -| **Fixtures** | `FixtureAlpha_oM` and `FixtureBeta_oM` in the CSharpSchema_Test repository, small assemblies written for the tests. Each type is there to provoke one situation: an enum member named `None`, an interface chain, a generic, a same-named type in two assemblies, a reference cycle, and so on. | Only `BHoM.dll` | Run anywhere | +| **Fixtures** | `FixtureAlpha_oM` and `FixtureBeta_oM` in `csharp/Fixtures`, small assemblies written for the tests. Each type is there to provoke one situation: an enum member named `None`, an interface chain, a generic, a same-named type in two assemblies, a reference cycle, and so on. | Only `BHoM.dll` | Run anywhere | | **Real types** | The actual BHoM oM, for example `ProjectIdentification`, `Line` and `Bar`. | The BHoM assemblies installed in `%ProgramData%\BHoM\Assemblies` | Ignored locally if missing; fail in CI | The fixtures exist so the logic can be tested precisely and without depending on whatever the BHoM `develop` branch looks like @@ -132,7 +132,7 @@ yet, or fails it when the `CI` environment variable is `true`. That is the Pytho A golden file is a committed copy of expected output. The test generates the output, compares it with the file, and fails on any difference. Use `golden/` when exact text matters: -- `golden/fixtures/`: the Python generated for a pinned list of fixture classes (one per situation, listed in `GoldenTests.m_PinnedClasses`), and their entries of the C# manifest. Classes added to CSharpSchema_Test later are not compared, so a merged C# change never needs a golden update; add a class to the list only for a situation no listed class covers. +- `golden/fixtures/`: the Python generated for eight fixture classes, one per output shape (a class with many field kinds, a reference cycle, an interface, a get-only class, a flags enum, a plain enum, a generic, a same-named class in another assembly). The list is `GoldenTests.m_PinnedClasses`; add a class only for a shape no listed class shows. The manifest has no golden file: the alignment tests cover it. - `golden/spike/`: a small, stable real type (`GradientCenteringOptions`). - `golden/py2cs/`: the C# that `py2cs` writes for small example classes. @@ -207,7 +207,7 @@ Almost every test follows **arrange, act, assert**. When a test fails, the repor | You changed | Add the test in | |---|---| -| How a C# type becomes Python text | `FixtureExtractionTests.cs` (add a type to `FixtureAlpha_oM` in CSharpSchema_Test if you need a new situation, then regenerate the golden files) | +| How a C# type becomes Python text | `FixtureExtractionTests.cs` (add a type to `FixtureAlpha_oM` in `csharp/Fixtures` if you need a new situation, then regenerate the golden files) | | Behaviour of the generated Python classes | `test_fixtures/test_generated_fixtures.py` | | Something specific to a real BHoM type | `RealTypeTests.cs` and `test_spike/` | | The Python to C# converter | `test_py2cs/` | diff --git a/docs/Testing-On-GitHub.md b/docs/Testing-On-GitHub.md index f06b478..fe28ac4 100644 --- a/docs/Testing-On-GitHub.md +++ b/docs/Testing-On-GitHub.md @@ -133,8 +133,8 @@ prints what it would do and proves the App token; unticked it does it. 3. Re-run **pr-checks**. `py2cs align` must now pass: the Python generated from the merged C# equals the Python in the PR. If it still fails, the message lists what differs; either the C# review changed something (copy the change into the Python) or the generator and `py2cs` disagree (a bug to fix in this repository). - The NUnit golden files cover a pinned list of fixture classes only, so a class merged into CSharpSchema_Test does not break them and no golden - update is needed. A test that deletes a fixture class file must pick a class that no other fixture imports. + The NUnit tests and their golden files use their own test classes (`.ci/unit-tests/csharp/Fixtures`), so a merged + C# change never needs a golden update. A test that deletes a fixture class file must pick a class that no other fixture imports. 4. Merge the Python PR. 5. Run *Python schema generation* live (or wait for Saturday). Expected: `No changes: the Python already matches the C#`. If it commits, the commit shows exactly how the generated Python differs from what was written by hand (often only formatting or From c1e05ca72dc26076517d7323360bc0b3dcff8722 Mon Sep 17 00:00:00 2001 From: Viet Le Date: Fri, 30 Oct 2026 10:57:48 +0000 Subject: [PATCH 3/5] Prevent raising C# PR without any changes --- .ci/generation/py2cs/github.py | 4 +++- .ci/generation/py2cs/pr.py | 6 ++++++ .../python/test_py2cs/test_linked_pr.py | 15 +++++++++++++++ docs/CODING-PLAN.md | 2 +- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.ci/generation/py2cs/github.py b/.ci/generation/py2cs/github.py index b91a2d1..55c8a22 100644 --- a/.ci/generation/py2cs/github.py +++ b/.ci/generation/py2cs/github.py @@ -136,7 +136,9 @@ def _request(self, method: str, path: str, body: dict[str, Any] | None = None, a if status >= 400: message = "" try: - message = str(json.loads(content).get("message", "")) + data = json.loads(content) + details = "; ".join(str(e.get("message") or e.get("code") or e) if isinstance(e, dict) else str(e) for e in data.get("errors", [])) + message = str(data.get("message", "")) + (f" ({details})" if details else "") except ValueError: pass raise GitHubError(f"GitHub {method} {path} failed with {status}: {message}") diff --git a/.ci/generation/py2cs/pr.py b/.ci/generation/py2cs/pr.py index 879828b..73d7925 100644 --- a/.ci/generation/py2cs/pr.py +++ b/.ci/generation/py2cs/pr.py @@ -82,6 +82,12 @@ def raise_pr(client: GitHubClient, plan_dir: Path, repo: str, python_pr: PythonP branch = branch_name(python_pr.number) base = client.default_branch(repo) if client.branch_sha(repo, branch) is None: + # The base already has every planned file (the C# pull request was merged): there is nothing to propose, and GitHub refuses a pull request with no commits + differing = [e for e in files if getattr(client.get_file(repo, base, e["path"]), "content", None) != (plan_folder(plan_dir, repo) / e["path"]).read_bytes()] + if not differing: + result.actions.append(Action("skip", repo, f"{base} already has the planned files, nothing to raise")) + return result + base_sha = client.branch_sha(repo, base) if base_sha is None: raise ValueError(f"{repo} has no branch {base}") diff --git a/.ci/unit-tests/python/test_py2cs/test_linked_pr.py b/.ci/unit-tests/python/test_py2cs/test_linked_pr.py index 56acd51..a6b0e5e 100644 --- a/.ci/unit-tests/python/test_py2cs/test_linked_pr.py +++ b/.ci/unit-tests/python/test_py2cs/test_linked_pr.py @@ -94,6 +94,21 @@ def test_running_again_changes_nothing(tmp_path: Path): assert len(remote.repositories[PYTHON_REPO].comments[7]) == 1, "the comment is updated, not repeated" assert any(a.kind == "unchanged" for a in again.actions) +def test_nothing_is_raised_when_the_base_already_has_the_planned_files(tmp_path: Path): + """Checks that raise_pr skips, creating no branch and no pull request, when the default branch already holds every planned file with the same content. + + Protects a pushed-to Python PR whose C# pull request was merged and its branch deleted: GitHub refuses a pull request with no commits. + """ + plan = written_plan(tmp_path) + remote = mock_github(REPO) + for path in (plan / REPO.replace("/", "__")).rglob("*.cs"): + remote.repositories[REPO].files[("develop", path.relative_to(plan / REPO.replace("/", "__")).as_posix())] = path.read_bytes() + + result = raise_pr(remote, plan, REPO, PR, python_client=remote) + assert remote.calls == [] + assert [a.kind for a in result.actions] == ["skip"] + + def test_a_changed_python_pr_updates_the_same_branch_and_pr(tmp_path: Path): """Checks that a changed plan updates the same branch and the same draft PR instead of opening another. diff --git a/docs/CODING-PLAN.md b/docs/CODING-PLAN.md index 9cad8bd..a6f960c 100644 --- a/docs/CODING-PLAN.md +++ b/docs/CODING-PLAN.md @@ -9,7 +9,7 @@ taken so far (section 9). ## Implementation status (phases 0 to 6 done, 7 and 8 not started) -Run `.ci/unit-tests/run-all.ps1`; it builds, generates, drafts, round-trips, runs NUnit (92 tests), pytest (195 tests) and Pyright. +Run `.ci/unit-tests/run-all.ps1`; it builds, generates, drafts, round-trips, runs NUnit (92 tests), pytest (197 tests) and Pyright. Where the implementation differs from the plan above: From 22f1b3eaf5d851b7c49c74a7d416a0ad3d3868aa Mon Sep 17 00:00:00 2001 From: Viet Le Date: Fri, 30 Oct 2026 11:14:00 +0000 Subject: [PATCH 4/5] Run tests on the PR's py2cs version --- .../python/test_py2cs/test_workflows.py | 10 ++++--- .github/workflows/linked-csharp-pr.yml | 27 +++++++++++++------ docs/Testing-On-GitHub.md | 12 +++++++++ docs/Workflows.md | 8 ++++-- 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/.ci/unit-tests/python/test_py2cs/test_workflows.py b/.ci/unit-tests/python/test_py2cs/test_workflows.py index d2bf0a2..111c8c2 100644 --- a/.ci/unit-tests/python/test_py2cs/test_workflows.py +++ b/.ci/unit-tests/python/test_py2cs/test_workflows.py @@ -91,13 +91,15 @@ def test_tokens_only_reach_the_steps_that_need_them(): plan_step = next(s for s in jobs["raise"]["steps"] if s.get("name") == "Plan the C# changes") assert "PY2CS_CSHARP_TOKEN" not in plan_step.get("env", {}), "planning does not need the token" -def test_the_tooling_that_holds_the_token_comes_from_the_base_branch(): - """Checks that the linked-PR workflow runs py2cs from the base branch checkout, not from the PR head. +def test_the_tooling_comes_from_the_pull_request_and_the_allowed_repositories_from_the_base(): + """Checks that the linked-PR workflow runs py2cs and the patcher from the PR head checkout, and reads the list of repositories a C# pull request may be raised in from the base. - Protects the token from code that a PR could change. + Protects the choice that a fix to the tooling works on its own pull request, and the list of where the App may write from being changed by that pull request. """ text = (WORKFLOWS / "linked-csharp-pr.yml").read_text(encoding="utf-8") - assert "PYTHONPATH: base/.ci/generation" in text and "head/.ci/generation" not in text + assert "PYTHONPATH: head/.ci/generation" in text and "PYTHONPATH: base/.ci/generation" not in text + assert "PY2CS_PATCHER: head/.ci/generation/" in text + assert "base/Converted-repositories.txt" in text and "head/Converted-repositories.txt" not in text def test_fork_pull_requests_get_no_linked_pull_request(): """Checks that the linked-PR workflow marks pull requests from forks as not eligible and that the repos job requires eligibility. diff --git a/.github/workflows/linked-csharp-pr.yml b/.github/workflows/linked-csharp-pr.yml index a4f274e..5fed3c0 100644 --- a/.github/workflows/linked-csharp-pr.yml +++ b/.github/workflows/linked-csharp-pr.yml @@ -93,7 +93,8 @@ jobs: matrix: ${{ steps.repos.outputs.matrix }} any: ${{ steps.repos.outputs.any }} steps: - # The tooling comes from the base branch, so a pull request cannot change the code that holds the App token + # The tooling (py2cs, the patcher) comes from the pull request, so a fix to it works on the same pull request. The Python before the change + # and the list of repositories a C# pull request may be raised in come from the base branch. - uses: actions/checkout@v4 with: ref: ${{ needs.prepare.outputs.base_sha }} @@ -112,7 +113,7 @@ jobs: id: repos shell: bash env: - PYTHONPATH: base/.ci/generation + PYTHONPATH: head/.ci/generation run: | repos=$(python -m py2cs repos --base-root base/src/bhom_schema --head-root head/src/bhom_schema --allowed-repos base/Converted-repositories.txt) echo "Repositories: $repos" @@ -167,13 +168,13 @@ jobs: python-version: '3.12' - name: Build the C# patcher - run: dotnet build base/.ci/generation/PythonSchemaGeneration.Patcher/PythonSchemaGeneration.Patcher.csproj -c Release --nologo + run: dotnet build head/.ci/generation/PythonSchemaGeneration.Patcher/PythonSchemaGeneration.Patcher.csproj -c Release --nologo - name: Plan the C# changes shell: bash env: - PYTHONPATH: base/.ci/generation - PY2CS_PATCHER: base/.ci/generation/PythonSchemaGeneration.Patcher/bin/Release/net8.0/PythonSchemaGeneration.Patcher.dll + PYTHONPATH: head/.ci/generation + PY2CS_PATCHER: head/.ci/generation/PythonSchemaGeneration.Patcher/bin/Release/net8.0/PythonSchemaGeneration.Patcher.dll run: | python -m py2cs plan \ --base-root base/src/bhom_schema --head-root head/src/bhom_schema \ @@ -186,7 +187,7 @@ jobs: - name: Push the branch and open or update the draft pull request shell: bash env: - PYTHONPATH: base/.ci/generation + PYTHONPATH: head/.ci/generation PY2CS_CSHARP_TOKEN: ${{ steps.token.outputs.token }} PY2CS_PYTHON_TOKEN: ${{ github.token }} DRY_RUN: ${{ needs.prepare.outputs.dry_run }} @@ -210,6 +211,11 @@ jobs: ref: ${{ needs.prepare.outputs.base_sha }} path: base + - uses: actions/checkout@v4 + with: + ref: ${{ needs.prepare.outputs.head_sha }} + path: head + - uses: actions/setup-python@v5 with: python-version: '3.12' @@ -227,7 +233,7 @@ jobs: - name: Close or comment on the linked pull request shell: bash env: - PYTHONPATH: base/.ci/generation + PYTHONPATH: head/.ci/generation PY2CS_CSHARP_TOKEN: ${{ steps.token.outputs.token }} DRY_RUN: ${{ needs.prepare.outputs.dry_run }} MERGED: ${{ needs.prepare.outputs.merged }} @@ -253,6 +259,11 @@ jobs: ref: ${{ needs.prepare.outputs.base_sha }} path: base + - uses: actions/checkout@v4 + with: + ref: ${{ needs.prepare.outputs.head_sha }} + path: head + - uses: actions/setup-python@v5 with: python-version: '3.12' @@ -260,7 +271,7 @@ jobs: - name: Set the commit status shell: bash env: - PYTHONPATH: base/.ci/generation + PYTHONPATH: head/.ci/generation PY2CS_PYTHON_TOKEN: ${{ github.token }} DRY_RUN: ${{ needs.prepare.outputs.dry_run }} run: | diff --git a/docs/Testing-On-GitHub.md b/docs/Testing-On-GitHub.md index fe28ac4..00da068 100644 --- a/docs/Testing-On-GitHub.md +++ b/docs/Testing-On-GitHub.md @@ -18,6 +18,18 @@ This procedure has not been run yet. Part 0 is done once; the three exercises ca CSharpSchema_Test with *Contents* and *Pull requests* write access, the secrets `BHOM_APP_ID` and `BHOM_APP_PRIVATE_KEY`, and the App (or `github-actions[bot]`) allowed to push to `develop` if it is protected. CSharpSchema_Test must be public. +**Protect the `develop` branch of the C# repository (once per C# repository).** The tooling of the linked PR runs from the Python pull +request, with a token that has *Contents: write*. Protecting `develop` means that token can open pull requests but never push to `develop`. +In CSharpSchema_Test: Settings, Rules, Rulesets, New ruleset, New branch ruleset: + +1. Name it `Protect develop`, set *Enforcement status* to **Active**, and leave the *Bypass list* empty (the App must not be on it). +2. Under *Target branches*, Add target, Include by pattern, `develop`. +3. Tick **Restrict deletions**, **Block force pushes** and **Require a pull request before merging** (required approvals can be 0 for this test repository). +4. Create. Then check it: a direct `git push origin develop` from a clone must be refused, while merging a pull request still works. + +(The older equivalent is Settings, Branches, Add branch protection rule, branch name pattern `develop`, with *Require a pull request before +merging* ticked. The real BHoM repositories already have this.) + **Check the starting point.** 1. Run *Python schema generation* from the Actions tab (branch `develop`, `dry_run` ticked). It must be green. Open the attached diff --git a/docs/Workflows.md b/docs/Workflows.md index 77e0d40..0d0f02f 100644 --- a/docs/Workflows.md +++ b/docs/Workflows.md @@ -149,8 +149,12 @@ rule: a Python PR is a proposal and is only merged after its C# PR. After the C# - The App token is made for one repository at a time and passed only to the step that needs it, through the environment. It is never printed, and error messages never contain it. -- The tooling that holds the token (`py2cs` and the patcher) is taken from the **base** branch, so a pull request cannot change the - code that runs with the token. +- The tooling (`py2cs` and the patcher) is taken from the **pull request**, so a fix to it works on the same pull request. That means + anybody who can push a branch to this repository can run code with the App token, which they could already do by editing the workflow + file itself; forks get nothing. What keeps this safe is the repository's own access: only trusted people have write access, the App + token is made for one repository at a time, and the `develop` branch of every C# repository is protected, so the App can open pull requests + but not push to `develop` (see "Protect the develop branch of the C# repository" in [Testing-On-GitHub.md](Testing-On-GitHub.md)). + The Python before the change, and the list of repositories a C# pull request may be raised in, still come from the base branch. - A pull request from a fork gets no linked pull request, because forks never receive the secrets. - The linked-PR workflow has no `push` trigger, so the weekly generation commit can never start it. - `.ci/generation/warnings-baseline.txt` lists the known kinds of generator warning. A new kind fails the weekly run, which means a From 727386cf593e11cd124e3d161ec62f2dd10f90e8 Mon Sep 17 00:00:00 2001 From: Viet Le Date: Fri, 30 Oct 2026 11:23:42 +0000 Subject: [PATCH 5/5] Skip an empty branch left over in C# --- .ci/generation/py2cs/pr.py | 13 +++++++------ .ci/unit-tests/python/test_py2cs/test_linked_pr.py | 7 ++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.ci/generation/py2cs/pr.py b/.ci/generation/py2cs/pr.py index 73d7925..369c46e 100644 --- a/.ci/generation/py2cs/pr.py +++ b/.ci/generation/py2cs/pr.py @@ -81,13 +81,14 @@ def raise_pr(client: GitHubClient, plan_dir: Path, repo: str, python_pr: PythonP branch = branch_name(python_pr.number) base = client.default_branch(repo) - if client.branch_sha(repo, branch) is None: - # The base already has every planned file (the C# pull request was merged): there is nothing to propose, and GitHub refuses a pull request with no commits - differing = [e for e in files if getattr(client.get_file(repo, base, e["path"]), "content", None) != (plan_folder(plan_dir, repo) / e["path"]).read_bytes()] - if not differing: - result.actions.append(Action("skip", repo, f"{base} already has the planned files, nothing to raise")) - return result + # The base already has every planned file (the C# pull request was merged) and no draft is open: there is nothing to propose, and GitHub + # refuses a pull request with no commits, whether or not the branch exists + in_sync = all((found := client.get_file(repo, base, e["path"])) is not None and found.content == (plan_folder(plan_dir, repo) / e["path"]).read_bytes() for e in files) + if in_sync and client.find_pull_request(repo, branch) is None: + result.actions.append(Action("skip", repo, f"{base} already has the planned files, nothing to raise")) + return result + if client.branch_sha(repo, branch) is None: base_sha = client.branch_sha(repo, base) if base_sha is None: raise ValueError(f"{repo} has no branch {base}") diff --git a/.ci/unit-tests/python/test_py2cs/test_linked_pr.py b/.ci/unit-tests/python/test_py2cs/test_linked_pr.py index a6b0e5e..efaf8ee 100644 --- a/.ci/unit-tests/python/test_py2cs/test_linked_pr.py +++ b/.ci/unit-tests/python/test_py2cs/test_linked_pr.py @@ -95,7 +95,7 @@ def test_running_again_changes_nothing(tmp_path: Path): assert any(a.kind == "unchanged" for a in again.actions) def test_nothing_is_raised_when_the_base_already_has_the_planned_files(tmp_path: Path): - """Checks that raise_pr skips, creating no branch and no pull request, when the default branch already holds every planned file with the same content. + """Checks that raise_pr skips, creating no branch and no pull request, when the default branch already holds every planned file with the same content and no draft is open, also when an empty branch is left over. Protects a pushed-to Python PR whose C# pull request was merged and its branch deleted: GitHub refuses a pull request with no commits. """ @@ -108,6 +108,11 @@ def test_nothing_is_raised_when_the_base_already_has_the_planned_files(tmp_path: assert remote.calls == [] assert [a.kind for a in result.actions] == ["skip"] + # An empty branch left by an earlier run changes nothing: still no pull request + remote.repositories[REPO].branches[branch_name(7)] = "sha-0" + assert [a.kind for a in raise_pr(remote, plan, REPO, PR, python_client=remote).actions] == ["skip"] + assert remote.calls == [] + def test_a_changed_python_pr_updates_the_same_branch_and_pr(tmp_path: Path): """Checks that a changed plan updates the same branch and the same draft PR instead of opening another.