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
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,13 @@ dotnet_diagnostic.IDE0161.severity = silent
[{**/Shared/**.cs,**/microsoft.extensions.hostfactoryresolver.sources/**.{cs,vb}}]
# IDE0005: Remove unused usings. Ignore for shared src files since imports for those depend on the projects in which they are included.
dotnet_diagnostic.IDE0005.severity = silent

# Verify settings
[*.{received,verified}.{json,txt,xml,ttl,nq}]
charset = utf-8-bom
end_of_line = lf
indent_size = unset
indent_style = unset
insert_final_newline = false
tab_width = unset
trim_trailing_whitespace = false
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.verified.txt text eol=lf working-tree-encoding=UTF-8
*.verified.xml text eol=lf working-tree-encoding=UTF-8
*.verified.json text eol=lf working-tree-encoding=UTF-8
*.verified.ttl text eol=lf working-tree-encoding=UTF-8
*.verified.nq text eol=lf working-tree-encoding=UTF-8
*.verified.bin binary
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/tmp/

###

*.received.*

############################################

TestResults/**
Expand Down
4 changes: 2 additions & 2 deletions OSLC4Net_SDK/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<PackageVersion Include="Aspire.Hosting.Testing" Version="$(AspireVersion)" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="10.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageVersion Include="Verify.XunitV3" Version="31.7.1" />
<PackageVersion Include="xunit.v3" Version="3.2.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageVersion Include="Meziantou.Extensions.Logging.Xunit.v3" Version="1.1.17" />
Expand All @@ -45,6 +46,5 @@
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" PrivateAssets="all" ExcludeAssets="runtime" />

</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference
Include="..\..\OSLC4Net.ChangeManagement\OSLC4Net.ChangeManagementCommon.csproj" />
<ProjectReference
Include="..\..\OSLC4Net.Core.DotNetRdfProvider\OSLC4Net.Core.DotNetRdfProvider.csproj" />
<ProjectReference Include="..\..\OSLC4Net.ChangeManagement\OSLC4Net.ChangeManagementCommon.csproj" />
<ProjectReference Include="..\..\OSLC4Net.Core.DotNetRdfProvider\OSLC4Net.Core.DotNetRdfProvider.csproj" />
<ProjectReference Include="..\..\OSLC4Net.Core\OSLC4Net.Core.csproj" />
</ItemGroup>
<ItemGroup>
Expand All @@ -18,6 +17,7 @@
<PackageReference Include="Meziantou.Extensions.Logging.Xunit.v3" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Verify.XunitV3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
using OSLC4Net.ChangeManagement;
using OSLC4Net.Core.DotNetRdfProvider;
using OSLC4Net.Core.Model;
using Xunit;

[assembly: CaptureConsole]
[assembly: CaptureTrace]
Expand Down Expand Up @@ -53,6 +52,8 @@ await DeserializeAsync<ChangeRequest>(formatter, rdfXml,
Assert.Equal(changeRequest1.IsFixed(), changeRequest2.IsFixed());
Assert.Equal(changeRequest1.GetAffectedByDefects()[0].GetValue(), changeRequest2.GetAffectedByDefects()[0].GetValue());
Assert.Equal(changeRequest1.GetAffectedByDefects()[0].GetLabel(), changeRequest2.GetAffectedByDefects()[0].GetLabel());

await Verify(changeRequest1);
}

[Fact]
Expand Down Expand Up @@ -115,6 +116,7 @@ await SerializeCollectionAsync(formatter, crListOut,
}
}

await Verify(rdfGraph);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.

_:c14n0 <http://purl.org/dc/terms/title> "Test of links";
rdf:object <http://com/somewhere/changeRequest1>;
rdf:predicate <http://open-services.net/ns/cm#affectedByDefect>;
rdf:subject <http://com/somewhere/changeRequest2>;
a rdf:Statement.
_:c14n1 <http://purl.org/dc/terms/title> "Test of links";
rdf:object <http://com/somewhere/changeRequest2>;
rdf:predicate <http://open-services.net/ns/cm#affectedByDefect>;
rdf:subject <http://com/somewhere/changeRequest1>;
a rdf:Statement.
<http://com/somewhere/changeRequest1> <http://open-services.net/ns/cm#affectedByDefect> <http://com/somewhere/changeRequest2>;
<http://open-services.net/ns/cm#fixed> true;
<http://open-services.net/ns/cm#severity> "Unclassified";
a <http://open-services.net/ns/cm#ChangeRequest>.
<http://com/somewhere/changeRequest2> <http://open-services.net/ns/cm#affectedByDefect> <http://com/somewhere/changeRequest1>;
<http://open-services.net/ns/cm#fixed> false;
<http://open-services.net/ns/cm#severity> "Unclassified";
a <http://open-services.net/ns/cm#ChangeRequest>.
<http://com/somewhere/changerequests> rdfs:member <http://com/somewhere/changeRequest1>,
<http://com/somewhere/changeRequest2>.
<http://com/somewhere/changerequests?page=20> <http://open-services.net/ns/core#nextPage> <http://com/somewhere/changerequests?page=21>;
<http://open-services.net/ns/core#totalCount> "2";
a <http://open-services.net/ns/core#ResponseInfo>.
Comment on lines +23 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

Verify totalCount data type against OSLC specification.

The collection and pagination structure are correct, but line 26 has totalCount as an untyped string literal "2" rather than a typed integer. According to OSLC Core specifications, totalCount should typically be an xsd:integer.

Please verify whether the serializer is correctly outputting type information for numeric properties. Check the OSLC Core specification for the expected data type of oslc:totalCount.

If the spec requires xsd:integer, the expected output should be:

-<http://com/somewhere/changerequests?page=20> <http://open-services.net/ns/core#nextPage> <http://com/somewhere/changerequests?page=21>;
-                                              <http://open-services.net/ns/core#totalCount> "2";
-                                              a <http://open-services.net/ns/core#ResponseInfo>.
+<http://com/somewhere/changerequests?page=20> <http://open-services.net/ns/core#nextPage> <http://com/somewhere/changerequests?page=21>;
+                                              <http://open-services.net/ns/core#totalCount> "2"^^xsd:integer;
+                                              a <http://open-services.net/ns/core#ResponseInfo>.

🌐 Web query:

OSLC Core specification totalCount data type xsd:integer

💡 Result:

Yes — OSLC Core defines oslc:totalCount as an integer (zero-or-one, optional). Its value SHOULD be non‑negative and, for query responses, SHOULD represent the total number of matching results. [1][2]

Sources:

  • OSLC Core — Vocabulary (totalCount = integer; SHOULD be non‑negative). [1]
  • OSLC Core — ResponseInfo shape (oslc:totalCount value-type: integer; occurrence: zero-or-one). [2]

Fix totalCount serialization to include xsd:integer type annotation.

Line 26 has totalCount as an untyped string literal "2", but OSLC Core defines oslc:totalCount as an integer (zero-or-one, optional). The RDF serializer should output the value with explicit type annotation:

-<http://com/somewhere/changerequests?page=20> <http://open-services.net/ns/core#nextPage> <http://com/somewhere/changerequests?page=21>;
-                                              <http://open-services.net/ns/core#totalCount> "2";
+<http://com/somewhere/changerequests?page=20> <http://open-services.net/ns/core#nextPage> <http://com/somewhere/changerequests?page=21>;
+                                              <http://open-services.net/ns/core#totalCount> "2"^^xsd:integer;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<http://com/somewhere/changerequests> rdfs:member <http://com/somewhere/changeRequest1>,
<http://com/somewhere/changeRequest2>.
<http://com/somewhere/changerequests?page=20> <http://open-services.net/ns/core#nextPage> <http://com/somewhere/changerequests?page=21>;
<http://open-services.net/ns/core#totalCount> "2";
a <http://open-services.net/ns/core#ResponseInfo>.
<http://com/somewhere/changerequests> rdfs:member <http://com/somewhere/changeRequest1>,
<http://com/somewhere/changeRequest2>.
<http://com/somewhere/changerequests?page=20> <http://open-services.net/ns/core#nextPage> <http://com/somewhere/changerequests?page=21>;
<http://open-services.net/ns/core#totalCount> "2"^^xsd:integer;
a <http://open-services.net/ns/core#ResponseInfo>.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.

_:c14n0 <http://purl.org/dc/terms/title> "Test of links";
rdf:object <http://com/somewhere/changeRequest2>;
rdf:predicate <http://open-services.net/ns/cm#affectedByDefect>;
rdf:subject <http://com/somewhere/changeReuest>;
a rdf:Statement.
<http://com/somewhere/changeReuest> <http://open-services.net/ns/cm#affectedByDefect> <http://com/somewhere/changeRequest2>;
<http://open-services.net/ns/cm#fixed> true;
<http://open-services.net/ns/cm#severity> "Unclassified";
a <http://open-services.net/ns/cm#ChangeRequest>.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System.Runtime.CompilerServices;
using EmptyFiles;
using OSLC4Net.Core.DotNetRdfProvider;
using OSLC4Net.Core.Model;
using VDS.RDF;
using VDS.RDF.Writing;

namespace OSLC4Net.Core.DotNetRdfProviderTests;

public static class VerifyInit
{
[ModuleInitializer]
public static void Initialize()
{
// or UseSourceFileRelativeDirectory
Verifier.UseProjectRelativeDirectory("Snapshots");

FileExtensions.AddTextExtension("ttl");

VerifierSettings.RegisterFileConverter<IGraph>(
(graph, _) =>
{
return CanonicalizeAndSerializeGraph(graph);
});
VerifierSettings.RegisterFileConverter<IResource>(
(resource, _) =>
{
var graph = DotNetRdfHelper.CreateDotNetRdfGraph([resource]);
return CanonicalizeAndSerializeGraph(graph);
});
}

private static ConversionResult CanonicalizeAndSerializeGraph(IGraph graph)
{
using var writer = new System.IO.StringWriter();
var rdfc = new RdfCanonicalizer();
using var graphCollection = new GraphCollection
{
{ graph, false }
};
using var tripleStore = new TripleStore(graphCollection);
var canonicalizedRdfDataset = rdfc.Canonicalize(tripleStore);
var newGraph = canonicalizedRdfDataset.OutputDataset.Graphs.Single();
// https://www.w3.org/TR/rdf-canon/ prescribes N-Quads serialization, but let's try Turtle for better readability
var ttlWriter = new CompressingTurtleWriter();
ttlWriter.Save(newGraph, writer);
return new ConversionResult(null, "ttl", writer.ToString());
}

}
Loading