Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 45 additions & 52 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>

<Project>

<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
</PropertyGroup>

<!--
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<!--
Floored packages - single source of truth. The redistributable libraries multi-target
netstandard2.1, where the referenced version becomes a minimum floor for every downstream
consumer, so these stable framework abstractions stay at an LTS version and are mirrored in
Expand All @@ -23,47 +20,43 @@

Raise a floored version only when a required API needs it or a CVE affects that package.
-->
<ItemGroup Label="Floored to LTS">
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.3" />
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
<PackageVersion Include="System.IO.Pipelines" Version="8.0.0" />
</ItemGroup>

<ItemGroup Label="Libraries">
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.7.0" />
<PackageVersion Include="MessagePack" Version="3.1.12" />
<PackageVersion Include="Microsoft.Sbom.Targets" Version="4.1.5" />
<PackageVersion Include="System.Text.Json" Version="10.0.11" />
</ItemGroup>

<ItemGroup Label="Code generator">
<PackageVersion Include="Antlr4.Runtime.Standard" Version="4.13.1" />
<PackageVersion Include="Microsoft.CodeAnalysis" Version="5.9.0" />
<PackageVersion Include="Microsoft.OpenApi" Version="3.10.2" />
<PackageVersion Include="uml4net.HandleBars" Version="9.1.0" />
<PackageVersion Include="uml4net.Reporting" Version="9.1.0" />
<PackageVersion Include="uml4net.xmi.Extensions.EnterpriseArchitect" Version="9.1.0" />
</ItemGroup>

<ItemGroup Label="Tests">
<PackageVersion Include="coverlet.collector" Version="10.0.1" />
<PackageVersion Include="coverlet.msbuild" Version="10.0.1" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="10.0.11" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="10.0.11" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.9.0" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="Npgsql" Version="10.0.3" />
<PackageVersion Include="NUnit" Version="4.6.1" />
<PackageVersion Include="NUnit.Console" Version="3.22.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="6.3.0" />
<PackageVersion Include="RichardSzalay.MockHttp" Version="7.0.0" />
<PackageVersion Include="Serilog" Version="4.4.0" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="10.0.0" />
<PackageVersion Include="Serilog.Sinks.Console" Version="6.1.1" />
<PackageVersion Include="XMLUnit.Core" Version="2.11.2" />
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.14.0" />
</ItemGroup>

</Project>
<ItemGroup Label="Floored to LTS">
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.3" />
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
<PackageVersion Include="System.IO.Pipelines" Version="8.0.0" />
</ItemGroup>
<ItemGroup Label="Libraries">
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.7.0" />
<PackageVersion Include="MessagePack" Version="3.1.12" />
<PackageVersion Include="Microsoft.Sbom.Targets" Version="4.1.13" />
<PackageVersion Include="System.Text.Json" Version="10.0.14" />
</ItemGroup>
<ItemGroup Label="Code generator">
<PackageVersion Include="Antlr4.Runtime.Standard" Version="4.13.1" />
<PackageVersion Include="Microsoft.CodeAnalysis" Version="5.9.0" />
<PackageVersion Include="Microsoft.OpenApi" Version="3.11.0" />
<PackageVersion Include="uml4net.HandleBars" Version="9.2.0" />
<PackageVersion Include="uml4net.Reporting" Version="9.2.0" />
<PackageVersion Include="uml4net.xmi.Extensions.EnterpriseArchitect" Version="9.2.0" />
</ItemGroup>
<ItemGroup Label="Tests">
<PackageVersion Include="coverlet.collector" Version="10.1.0" />
<PackageVersion Include="coverlet.msbuild" Version="10.1.0" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="10.0.14" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="10.0.14" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.11.0" />
<PackageVersion Include="Moq" Version="4.21.0" />
<PackageVersion Include="Npgsql" Version="10.0.3" />
<PackageVersion Include="NUnit" Version="5.0.0" />
<PackageVersion Include="NUnit.Console" Version="3.22.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="6.3.1" />
<PackageVersion Include="RichardSzalay.MockHttp" Version="7.1.0" />
<PackageVersion Include="Serilog" Version="4.4.0" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="10.0.0" />
<PackageVersion Include="Serilog.Sinks.Console" Version="6.1.1" />
<PackageVersion Include="XMLUnit.Core" Version="2.11.2" />
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.16.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,6 @@ public void Verify_that_WriteCountAllNonDerivedProperties_writes_numeric_count()
Assert.That(count, Is.GreaterThanOrEqualTo(0));
}

[Test]
public void Verify_that_QueryAllNonDerivedNonRedefinedProperties_does_not_throw()
{
var testClass = this.allClasses.First(c => !c.IsAbstract && c.QueryAllNonDerivedNonRedefinedProperties().Count > 0);

Assert.That(() => this.RenderWithClassContext(
"{{#Class.QueryAllNonDerivedNonRedefinedProperties}}item{{/Class.QueryAllNonDerivedNonRedefinedProperties}}",
testClass), Throws.Nothing);
}

[Test]
public void Verify_that_QueryAllNonDerivedNonRedefinedProperties_returns_expected_count()
{
Expand Down
40 changes: 0 additions & 40 deletions SysML2.NET.CodeGenerator/Extensions/ClassExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace SysML2.NET.CodeGenerator.Extensions
{
using System.Collections.ObjectModel;
using System.Linq;

using uml4net.Classification;
Expand All @@ -21,45 +20,6 @@ namespace SysML2.NET.CodeGenerator.Extensions
/// </summary>
public static class ClassExtensions
{
/// <summary>
/// Queries all the properties that are implemented by the class directly or through superclasses
/// or interface implementations EXCLUDING IsDerived
/// </summary>
/// <param name="class">
/// The <see cref="IClass" /> from which to query the properties
/// </param>
/// <returns>
/// A <see cref="ReadOnlyCollection{T}" /> of <see cref="IProperty" />
/// </returns>
public static ReadOnlyCollection<IProperty> QueryAllNonDerivedProperties(this IClass @class)
{
var properties = @class.QueryAllProperties()
.Where(x => !x.IsDerived);

return properties.ToList().AsReadOnly();
}

/// <summary>
/// Queries all the properties that are implemented by the class directly or through superclasses
/// or interface implementations EXCLUDING IsDerived and EXCLUDING properties that have been
/// redefined in the context of the current class
/// </summary>
/// <param name="class">
/// The <see cref="IClass" /> from which to query the properties
/// </param>
/// <returns>
/// A <see cref="ReadOnlyCollection{T}" /> of <see cref="IProperty" />
/// </returns>
public static ReadOnlyCollection<IProperty> QueryAllNonDerivedNonRedefinedProperties(this IClass @class)
{
var properties = @class.QueryAllProperties()
.Where(x => !x.IsDerived)
.Where(x => !x.TryQueryRedefinedByProperty(@class, out _))
.OrderBy(x => x.Name);

return properties.ToList().AsReadOnly();
}

/// <summary>
/// Counts and returns to amount of non derived properties
/// </summary>
Expand Down
31 changes: 0 additions & 31 deletions SysML2.NET.CodeGenerator/Extensions/PropertyExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,6 @@ namespace SysML2.NET.CodeGenerator.Extensions
/// </summary>
public static class PropertyExtension
{
/// <summary>
/// Asserts that the <see cref="IProperty"/> is an enum type with a default value provided
/// </summary>
/// <param name="property">The <see cref="IProperty"/> to assert</param>
/// <returns>True if the <see cref="IProperty"/> have a default value for an enum</returns>
public static bool QueryIsEnumPropertyWithDefaultValue(this IProperty property)
{
ArgumentNullException.ThrowIfNull(property);

if (!property.QueryIsEnum())
{
return false;
}

var defaultValue = property.QueryDefaultValueAsString();

if (defaultValue == "null")
{
return false;
}

var valueSpecification = property.DefaultValue.FirstOrDefault();

if (valueSpecification is IInstanceValue instanceValue)
{
return instanceValue.Instance is IEnumerationLiteral;
}

return false;
}

/// <summary>
/// Gets the name of the property.
/// </summary>
Expand Down
12 changes: 0 additions & 12 deletions SysML2.NET.CodeGenerator/HandleBarHelpers/ClassHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
{
if (context.Value is not IClass @class)
{
throw new ArgumentException("supposed to be IClass");

Check warning on line 47 in SysML2.NET.CodeGenerator/HandleBarHelpers/ClassHelper.cs

View workflow job for this annotation

GitHub Actions / Build

Define a constant instead of using this literal 'supposed to be IClass' 5 times.
}

var uniqueNamespaces = new HashSet<string>();
Expand Down Expand Up @@ -159,18 +159,6 @@
writer.WriteSafeString(@class.CountAllNonDerivedProperties());
});

// Queries all the properties that are non derived and not redefined in the
// context of the current class
handlebars.RegisterHelper("Class.QueryAllNonDerivedNonRedefinedProperties", (context, _) =>
{
if (!(context.Value is IClass @class))
{
throw new ArgumentException("#Class.QueryAllNonDerivedNonRedefinedProperties: supposed to be IClass");
}

return @class.QueryAllNonDerivedNonRedefinedProperties();
});

// writes the count of non-derived and non Redefined properties of the IClass
handlebars.RegisterHelper("Class.WriteCountAllNonDerivedNonRedefinedProperties", (writer, context, _) =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ public async Task Verify_that_ReadAllBytesAsync_throws_on_null_stream()
{
Stream stream = null;

var ex = Assert.ThrowsAsync<ArgumentNullException>(async () =>
await stream.ReadAllBytesAsync(CancellationToken.None));

Assert.That(ex!.ParamName, Is.EqualTo("stream"));
await Assert.ThatAsync(async () => await stream.ReadAllBytesAsync(CancellationToken.None),
Throws.ArgumentNullException.With.Property(nameof(ArgumentNullException.ParamName)).EqualTo("stream"));
}

[Test]
Expand Down
Loading