Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
Updated to latest IDS repository structure.
  • Loading branch information
CBenghi committed Sep 18, 2024
2 parents b1f902b + 8d11214 commit 57353ec
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 28 deletions.
21 changes: 11 additions & 10 deletions SolutionTooling/BuildingSmartRepoFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private static string IdsRepoPath
if (subIDS != null)
{
if (
subIDS.GetDirectories("Development").Any()
subIDS.GetDirectories("RepositoryAutomation").Any()
&& subIDS.GetDirectories(".nuke").Any()
)
return subIDS.FullName;
Expand Down Expand Up @@ -49,8 +49,9 @@ private static string IdsToolRepoPath
}

// private static string IfcOpenShellTestcasesPath => Path.Combine(IfcOpenShellPath, "src", "ifctester", "test", "build", "testcases");
private static string IdsRepositoryTestcasesPath => Path.Combine(IdsRepositoryDocumentationPath, "testcases");
private static string IdsRepositoryDevelopmentPath => Path.Combine(IdsRepoPath, @"Development");
private static string IdsRepositoryTestcasesPath => Path.Combine(IdsRepositoryDocumentationPath, "ImplementersDocumentation", "TestCases");
private static string IdsRepositorySchemaPath => Path.Combine(IdsRepoPath, @"Schema");
private static string IdsRepositoryExamplePath => Path.Combine(IdsRepoPath, "Documentation", @"Examples");
private static string IdsRepositoryDocumentationPath => Path.Combine(IdsRepoPath, @"Documentation");

public static FileInfo GetIdsToolSchema()
Expand All @@ -67,7 +68,7 @@ public static FileInfo GetIdsTestSuiteSchema()

public static FileInfo GetIdsSchema()
{
var schema = Path.Combine(IdsRepositoryDevelopmentPath, "ids.xsd");
var schema = Path.Combine(IdsRepositorySchemaPath, "ids.xsd");
return new FileInfo(schema);
}

Expand Down Expand Up @@ -106,18 +107,18 @@ private static IEnumerable<object[]> GetFilesOrEmpty(DirectoryInfo d, string sea
}
}

public static FileInfo GetIdsRepositoryDevelopmentFileInfo(string idsFile)
public static FileInfo GetIdsRepositoryExampleFileInfo(string idsFile)
{
var d = new DirectoryInfo(IdsRepositoryDevelopmentPath);
var d = new DirectoryInfo(IdsRepositoryExamplePath);
var comb = d.FullName + idsFile;
var f = new FileInfo(comb);
return f;
}

public static IEnumerable<object[]> GetIdsRepositoryDevelopmentIdsFiles()
public static IEnumerable<object[]> GetIdsRepositoryExampleIdsFiles()
{
// start from current directory and look in relative position for the bs IDS repository
var d = new DirectoryInfo(IdsRepositoryDevelopmentPath);
var d = new DirectoryInfo(IdsRepositoryExamplePath);
if (!d.Exists)
{
// returning a single invalid entry so that it can be skipped
Expand All @@ -136,9 +137,9 @@ public static FileInfo GetDocumentation(string fileName)
return new FileInfo(Path.Combine(IdsRepositoryDocumentationPath, fileName));
}

public static FileInfo GetDevelopment(string fileName)
public static FileInfo GetSchemaPath(string fileName)
{
return new FileInfo(Path.Combine(IdsRepositoryDevelopmentPath, fileName));
return new FileInfo(Path.Combine(IdsRepositorySchemaPath, fileName));
}

public static bool FilesAreIdentical(FileInfo repoSchema, FileInfo toolSchema)
Expand Down
4 changes: 2 additions & 2 deletions ids-lib.codegen/IdsRepo_Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private static IEnumerable<UpdatableFile> UpdateDocumentationUnits(DirectoryInfo

private static IEnumerable<UpdatableFile> UpdateEmbeddedSchema(DirectoryInfo solutionDir)
{
var sourceFile = BuildingSmartRepoFiles.GetDevelopment("ids.xsd");
var sourceFile = BuildingSmartRepoFiles.GetSchemaPath("ids.xsd");
if (sourceFile.Exists)
{
var destination = Path.Combine(
Expand All @@ -178,7 +178,7 @@ private static IEnumerable<UpdatableFile> UpdateEmbeddedSchema(DirectoryInfo sol

private static IEnumerable<UpdatableFile> UpdateTestingSchema(DirectoryInfo solutionDir)
{
var sourceFile = BuildingSmartRepoFiles.GetDevelopment("ids.xsd");
var sourceFile = BuildingSmartRepoFiles.GetSchemaPath("ids.xsd");
if (sourceFile.Exists)
{
var destination = Path.Combine(
Expand Down
21 changes: 15 additions & 6 deletions ids-lib/IfcSchema/SchemaInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,16 @@ internal static IEnumerable<string> PossibleTypesForPropertySets(IfcSchemaVersio
{
var tp = schema[item];
if (tp is not null && tp.RelationTypeClasses is not null)
{
typeObjects.AddRange(tp.RelationTypeClasses);
// RelationTypeClasses only includes immediate ancestors, so we need to include all subClasses of any TypeObjects
// as these also are valid for the propertySet
var subTypes = tp.RelationTypeClasses.SelectMany(typ => schema[typ]!.SubClasses.Select(s => s.Name)).Distinct();
if(subTypes.Any())
{
typeObjects.AddRange(subTypes);
}
}
}
if (typeObjects.Any())
thisPsetTypes = thisPsetTypes.ToList().Concat(typeObjects.Distinct()).ToList();
Expand Down Expand Up @@ -552,24 +561,24 @@ public static IEnumerable<string> GetConcreteClassesFrom(string topClass, IfcSch
{
if (schemaVersions.IsSingleSchema())
{
var schema = GetSchemas(schemaVersions).First();
var schema = GetSchemas(schemaVersions).First();
if (schema is null)
return Enumerable.Empty<string>();
var top = schema[topClass];
if (top is null)
return Enumerable.Empty<string>();
return top.MatchingConcreteClasses.Select(x=>x.Name);
}
return top.MatchingConcreteClasses.Select(x=>x.Name);
}

var schemas = GetSchemas(schemaVersions);
var schemas = GetSchemas(IfcSchemaVersions.IfcAllVersions);
List<string> ret = new();
foreach (var schema in schemas)
foreach (var schema in schemas)
{
var top = schema[topClass];
if (top is null)
continue;
ret = ret.Union(top.MatchingConcreteClasses.Select(x => x.Name)).ToList();
}
}
return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion ids-lib/LibraryInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ public static class LibraryInformation
/// <summary>
/// Static field with hardcoded DLL version number.
/// </summary>
public static string AssemblyVersion => "1.0.77";
public static string AssemblyVersion => "1.0.78";
}
2 changes: 1 addition & 1 deletion ids-lib/ids-lib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PackageReleaseNotes>First implementation.</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<!-- Github actions are setup so that when this version is bumped the nuget package is uploaded -->
<AssemblyVersion>1.0.77</AssemblyVersion>
<AssemblyVersion>1.0.78</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<Version>$(AssemblyVersion)</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
4 changes: 2 additions & 2 deletions ids-tool.tests/AuditTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public AuditTests(ITestOutputHelper outputHelper)
private ITestOutputHelper XunitOutputHelper { get; }

[SkippableTheory]
[MemberData(nameof(GetIdsRepositoryDevelopmentIdsFiles))]
[MemberData(nameof(GetIdsRepositoryExampleIdsFiles))]
public void FullAuditOfDevelopmentFilesOk(string developmentIdsFile)
{
Skip.If(developmentIdsFile == string.Empty, "IDS repository folder not available for extra tests.");
Expand All @@ -34,7 +34,7 @@ public void FullAuditOfDevelopmentFilesOk(string developmentIdsFile)
}

[SkippableTheory]
[MemberData(nameof(GetIdsRepositoryDevelopmentIdsFiles))]
[MemberData(nameof(GetIdsRepositoryExampleIdsFiles))]
public void FullAuditOfDevelopmentFilesWithItsSchemaOk(string developmentIdsFile)
{
var repoSchema = BuildingSmartRepoFiles.GetIdsSchema();
Expand Down
2 changes: 1 addition & 1 deletion ids-tool.tests/Helpers/LoggerAndAuditHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal static class LoggerAndAuditHelpers
{
public static FileInfo GetAndCheckIdsRepositoryDevelopmentFileInfo(string theFile)
{
FileInfo f = BuildingSmartRepoFiles.GetIdsRepositoryDevelopmentFileInfo(theFile);
FileInfo f = BuildingSmartRepoFiles.GetIdsRepositoryExampleFileInfo(theFile);
f.Exists.Should().BeTrue("test file must be found");
return f;
}
Expand Down
2 changes: 1 addition & 1 deletion ids-tool.tests/IdsInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task InvalidFilesDontBreak(string idsFile, bool isIds)
}

[SkippableTheory]
[MemberData(nameof(GetIdsRepositoryDevelopmentIdsFiles))]
[MemberData(nameof(GetIdsRepositoryExampleIdsFiles))]
public async Task CanReadIdsDevelopmentFiles(string idsFile)
{
Skip.If(idsFile == string.Empty, "IDS repository folder not available for extra tests.");
Expand Down
31 changes: 30 additions & 1 deletion ids-tool.tests/IfcSchemaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,20 @@ public void CanGetConcreteSubclasses()

}

[Theory]
[Fact]
public void CanGetConcreteSubclassesForSpecificSchema()
{
// IFCCABLECARRIERSEGMENT is new in IFC4
var elements = SchemaInfo.GetConcreteClassesFrom("IFCCABLECARRIERSEGMENT", IfcSchemaVersions.Ifc4);
elements.Should().NotBeNull();
elements.Should().HaveCount(1);

elements = SchemaInfo.GetConcreteClassesFrom("IFCFACILITYPART", IfcSchemaVersions.Ifc4x3);
elements.Should().Contain("IfcRailwayPart");
elements.Should().HaveCount(5);
}

[Theory]
[InlineData("IFCOBJECTDEFINITION", 194,366)]
[InlineData("IFCWALL",2, 3)]
[InlineData("IFCNOTEXISTING",-1, -1)]
Expand Down Expand Up @@ -228,5 +241,21 @@ public void OnlyTopLevelClassesShouldRemoveAllSubClasses()
}


[Fact]
public void AllSubClassesOfTypesAreIncludedAsPossibleTypesForPropertySets()
{
var psets = new[] { "Pset_ManufacturerTypeInformation" };
var classes = SchemaInfo.PossibleTypesForPropertySets(IfcSchemaVersions.Ifc2x3, psets).Select(e=> e.ToUpperInvariant());

// Sanity checking
classes.Should().Contain("IFCWALL");
classes.Should().Contain("IFCWALLTYPE");
classes.Should().Contain("IFCDISTRIBUTIONCONTROLELEMENT");

// Bug - IFC2x3 Type Subtypes were not being returned: Issue #39
classes.Should().Contain("IFCACTUATORTYPE");
classes.Should().Contain("IFCAIRTERMINALTYPE");
}


}
27 changes: 27 additions & 0 deletions ids-tool.tests/IssueFiles/Issue 39 - IfcTypeObjects allowed.ids
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<ids xmlns="http://standards.buildingsmart.org/IDS" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://standards.buildingsmart.org/IDS http://standards.buildingsmart.org/IDS/1.0/ids.xsd">
<info>
<title>Can select IfcTypeObjects that don't have equivalent IfcObject in IFC2x3</title>
</info>
<specifications>
<specification ifcVersion="IFC2X3" name="IfcActuatorType.ModelLabel"
description="Issue is that there's no IFCACTUATOR instance in IFC2x3 so we get a false 'Inconsistent Clauses' 201 error, since subClasses were not being considered">
<applicability minOccurs="0" maxOccurs="unbounded">
<entity>
<name>
<simpleValue>IFCACTUATORTYPE</simpleValue>
</name>
</entity>
</applicability>
<requirements>
<property dataType="IFCLABEL">
<propertySet>
<simpleValue>Pset_ManufacturerTypeInformation</simpleValue>
</propertySet>
<baseName>
<simpleValue>ModelLabel</simpleValue>
</baseName>
</property>
</requirements>
</specification>
</specifications>
</ids>
9 changes: 8 additions & 1 deletion ids-tool.tests/IssueTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,12 @@ public void Issue_30_ShouldReturnError()
var f = new FileInfo("IssueFiles/Issue 30 - should return error.ids");
LoggerAndAuditHelpers.FullAudit(f, XunitOutputHelper, IdsLib.Audit.Status.IdsContentError, 2);
}
}

[Fact]
public void Issue_39_SubClassesOfObjectTypesAllowPsets()
{
var f = new FileInfo("IssueFiles/Issue 39 - IfcTypeObjects allowed.ids");
LoggerAndAuditHelpers.FullAudit(f, XunitOutputHelper, IdsLib.Audit.Status.Ok);
}
}
}
2 changes: 1 addition & 1 deletion ids-tool.tests/SchemaLoadingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public SchemaLoadingTests(ITestOutputHelper outputHelper)
/// In case this test fails, see <see cref="AuditTests.FullAuditOfDevelopmentFilesOk"/> for issues in the file.
/// </summary>
[SkippableTheory]
[MemberData(nameof(GetIdsRepositoryDevelopmentIdsFiles))]
[MemberData(nameof(GetIdsRepositoryExampleIdsFiles))]
public void CanLoadEmbeddedResourceSchema(string idsFile)
{
Skip.If(idsFile == string.Empty, "IDS repository folder not available for extra tests.");
Expand Down
3 changes: 3 additions & 0 deletions ids-tool.tests/ids-tool.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@
<None Update="IssueFiles\Issue 08 - Regex pattern.ids">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="IssueFiles\Issue 39 - IfcTypeObjects allowed.ids">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="IssueFiles\Issue 11 - IfcLogical.ids">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
2 changes: 1 addition & 1 deletion ids-tool/ids-tool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageIcon>icon.png</PackageIcon>
<PackageTags>IDS, buildingSmart</PackageTags>
<!-- Github actions are setup so that when this version is bumped the nuget package is uploaded -->
<AssemblyVersion>1.0.77</AssemblyVersion>
<AssemblyVersion>1.0.78</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<Version>$(AssemblyVersion)</Version>
<RepositoryUrl>https://github.com/buildingSMART/IDS-Audit-tool.git</RepositoryUrl>
Expand Down

0 comments on commit 57353ec

Please sign in to comment.