Skip to content

Commit 5adb564

Browse files
OSLC Client improvements + cover with Aspire integration test (#316)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent fe30ed7 commit 5adb564

File tree

168 files changed

+3931
-3572
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+3931
-3572
lines changed

.editorconfig

+6-6
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ csharp_prefer_braces = true # Prefer curly braces even for one line of code
5959

6060
# name all constant fields using PascalCase
6161
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
62-
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
63-
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
64-
dotnet_naming_symbols.constant_fields.applicable_kinds = field
62+
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
63+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
64+
dotnet_naming_symbols.constant_fields.applicable_kinds = field
6565
dotnet_naming_symbols.constant_fields.required_modifiers = const
6666
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
6767

6868
# internal and private fields should be _camelCase
6969
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
70-
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
71-
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
70+
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
71+
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
7272
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
7373
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
7474
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
@@ -297,7 +297,7 @@ dotnet_diagnostic.IDE0031.severity = warning
297297
dotnet_diagnostic.IDE0035.severity = warning
298298

299299
# IDE0036: Order modifiers
300-
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
300+
csharp_preferred_modifier_order = public, private, protected, internal, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async:suggestion
301301
dotnet_diagnostic.IDE0036.severity = warning
302302

303303
# IDE0038: Use pattern matching to avoid is check followed by a cast (without variable)

.github/workflows/main.yml

+20-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
fail-fast: false
4646
matrix:
4747
os: [ubuntu-24.04, ubuntu-24.04-arm, windows-latest]
48-
version:
48+
version:
4949
[
5050
# { setup: "6.x", target: "net6.0" },
5151
{ setup: "8.x", target: "net8.0" },
@@ -55,7 +55,7 @@ jobs:
5555
runs-on: ${{ matrix.os }}
5656
defaults:
5757
run:
58-
working-directory: OSLC4Net_SDK/
58+
working-directory: main/OSLC4Net_SDK/
5959
env:
6060
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
6161
# TAG_VALUE: ${{ github.ref_name || inputs.version }}
@@ -64,12 +64,19 @@ jobs:
6464
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
6565
with:
6666
egress-policy: audit
67-
6867
- name: Checkout Code
6968
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
7069
with:
7170
show-progress: false
7271
persist-credentials: false
72+
path: main
73+
- name: Checkout Code
74+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
75+
with:
76+
show-progress: false
77+
persist-credentials: false
78+
repository: oslc-op/refimpl
79+
path: refimpl
7380
- name: Setup .NET
7481
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
7582
with:
@@ -95,6 +102,9 @@ jobs:
95102
(Get-Content Tests/OSLC4Net.Core.QueryTests/OSLC4Net.Core.QueryTests.csproj) |
96103
ForEach-Object { $_ -replace '>net8.0<', '>${{ matrix.version.target }}<' } |
97104
Set-Content Tests/OSLC4Net.Core.QueryTests/OSLC4Net.Core.QueryTests.csproj
105+
(Get-Content Tests/OSLC4Net.Test.AspireHost/OSLC4Net.Test.AspireHost.csproj) |
106+
ForEach-Object { $_ -replace '>net8.0<', '>${{ matrix.version.target }}<' } |
107+
Set-Content Tests/OSLC4Net.Test.AspireHost/OSLC4Net.Test.AspireHost.csproj
98108
- name: Cache NuGet
99109
# id: cache-nuget
100110
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
@@ -108,8 +118,14 @@ jobs:
108118
run: dotnet restore
109119
- name: Build
110120
run: dotnet build --no-restore
111-
- name: Test
121+
- name: Test (with Refimpl CM tests)
122+
run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage"
123+
if: |
124+
matrix.os != 'windows-latest'
125+
- name: Test (without Refimpl CM tests)
112126
run: dotnet test --no-build --verbosity normal --filter TestCategory!=RunningOslcServerRequired --collect:"XPlat Code Coverage"
127+
if: |
128+
matrix.os == 'windows-latest'
113129
# - name: Set version suffix
114130
# id: version
115131
# run: echo "::set-output name=suffix::$(date +'-ts.%y%m%d%H%M')"

CHANGELOG.md

+13-6
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
Legend: 🔒️ security fixes; ⚡️ major features/updates; ❗️ breaking changes; 👉 important notes.
99

1010

11-
## [UNRELEASED] - YYYY-MM-DD
11+
## [0.5.0] - 2024-11-15
1212

1313
### Security
1414

1515
This release does not contain security updates.
1616

1717
### Added
1818

19-
This release does not contain new features.
19+
- ⚡️ CI integration tests against OSLC RefImpl based on NET Aspire
20+
- Redirect loop protection for `OslcClient` (max 20 redirects as in Firefox/Blink/WebKit)
21+
- Follow redirects on more responses statuses (was: 301, became: 301, 302, 307, 308, and in case of GET requests, 303 too)
22+
- ❗️ `OslcResponse` can now expose multiple response resources, the `Graph` and, in case of error, the `oslc:Error` resource.
2023

2124
### Changed
2225

2326
- dotNetRDF dependency was updated to v3.3.1
27+
- ❗️ `OslcClient` was updated to consistently support async operations
2428

2529
### Deprecated
2630

27-
This release does not introduce deprecations.
31+
- Most non-async methods in client classes.
32+
- Further OSLC JSON deprecations. Clients should rely on RDF instead (RDF/XML, Turtle)
2833

2934
### Removed
3035

31-
This release does not remove any features.
36+
- ❗️ Multiple non-async methods in `OslcClient`
37+
- ❗️ A property exposing `OslcRestClient` in `ServiceProviderRegistryClient`
3238

3339
### Fixed
3440

35-
This release does not contain bug fixes.
41+
- Minor bug fixes to pass acceptance tests against OSLC RefImpl Change Management server.
3642

3743

3844
## [0.4.6] - 2024-11-15
@@ -271,7 +277,8 @@ This release does not remove any features.
271277
This release does not contain bug fixes.
272278

273279

274-
[UNRELEASED]: https://github.com/OSLC/oslc4net/compare/v0.4.6...HEAD
280+
[UNRELEASED]: https://github.com/OSLC/oslc4net/compare/v0.5.0...HEAD
281+
[0.5.0]: https://github.com/OSLC/oslc4net/releases/tag/v0.5.0
275282
[0.4.6]: https://github.com/OSLC/oslc4net/releases/tag/v0.4.6
276283
[0.4.5]: https://github.com/OSLC/oslc4net/releases/tag/v0.4.5
277284
[0.4.4]: https://github.com/OSLC/oslc4net/releases/tag/v0.4.4

OSLC4Net_SDK/Directory.Build.props

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
<PropertyGroup>
77
<Version Condition="'$(RELEASE_VERSION)' != ''">$(RELEASE_VERSION)</Version>
8-
<VersionPrefix Condition="'$(RELEASE_VERSION)' == ''">999.9.9</VersionPrefix>
9-
<VersionSuffix Condition="'$(RELEASE_VERSION)' == ''">ts.$([System.DateTime]::UtcNow.ToString(`yyyyMMddHHmm`))</VersionSuffix>
8+
<VersionPrefix Condition="'$(RELEASE_VERSION)' == ''">99.99.99.9999</VersionPrefix>
109
<PackageLicenseExpression>EPL-1.0</PackageLicenseExpression>
1110
<Authors>Andrii Berezovskyi and OSLC4Net contributors</Authors>
1211
<Copyright>© Andrii Berezovskyi and OSLC4Net contributors 2023; © IBM 2012</Copyright>
@@ -25,8 +24,8 @@
2524

2625

2726
<ItemGroup>
28-
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/>
29-
<None Include="$(SolutionDir)\..\README.md" Pack="true" PackagePath="README.md"/>
27+
<SourceRoot Include="$(MSBuildThisFileDirectory)/" />
28+
<None Include="$(SolutionDir)\..\README.md" Pack="true" PackagePath="README.md" />
3029
</ItemGroup>
3130

3231
<PropertyGroup>
@@ -35,6 +34,8 @@
3534
<ImplicitUsings>enable</ImplicitUsings>
3635
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
3736
<!-- fail on any NuGet vulnerability audit findings -->
38-
<WarningsAsErrors>NU1900;NU1901;NU1902;NU1903;NU1904</WarningsAsErrors>
37+
<NugetWarnings>NU1900;NU1901;NU1902;NU1903;NU1904</NugetWarnings>
38+
<NullabilityWarnings>CS8600;CS8602;CS8603</NullabilityWarnings>
39+
<WarningsAsErrors>$(NugetWarnings);$(NullabilityWarnings)</WarningsAsErrors>
3940
</PropertyGroup>
4041
</Project>

OSLC4Net_SDK/Directory.Packages.props

+29-28
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,41 @@
55
</PropertyGroup>
66
<PropertyGroup>
77
<!-- Versions used by several individual references below -->
8-
<MSTestVersion>3.8.3</MSTestVersion>
8+
<AspireVersion>9.1.0</AspireVersion>
99
</PropertyGroup>
1010
<ItemGroup>
1111
<!-- For removal -->
12-
<PackageVersion Include="log4net" Version="2.0.17" />
13-
<PackageVersion Include="NuGet.Build.Tasks.Pack" Version="6.12.1" />
14-
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
15-
<PackageVersion Include="System.Json" Version="4.8.0" />
12+
<PackageVersion Include="log4net" Version="2.0.17"/>
13+
<PackageVersion Include="NuGet.Build.Tasks.Pack" Version="6.12.1"/>
14+
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3"/>
15+
<PackageVersion Include="System.Json" Version="4.8.0"/>
1616
<!-- depedencyManagement / convergence -->
17-
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
18-
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
17+
<PackageVersion Include="System.Net.Http" Version="4.3.4"/>
18+
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1"/>
1919
<!-- Main deps -->
20-
<PackageVersion Include="dotNetRdf.Core" Version="3.3.2" />
21-
<PackageVersion Include="Antlr3.Runtime" Version="3.5.1" />
22-
<PackageVersion Include="CommunityToolkit.Diagnostics" Version="8.4.0" />
20+
<PackageVersion Include="dotNetRdf.Core" Version="3.3.2"/>
21+
<PackageVersion Include="Antlr3.Runtime" Version="3.5.1"/>
22+
<PackageVersion Include="CommunityToolkit.Diagnostics" Version="8.4.0"/>
2323
<!-- conneg support &c for System.Net.Http -->
24-
<PackageVersion Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
24+
<PackageVersion Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0"/>
2525
<!-- Test deps -->
26-
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.4" />
27-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
28-
<PackageVersion Include="xunit" Version="2.9.3" />
29-
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2" />
30-
<PackageVersion Include="NSubstitute" Version="5.3.0" />
31-
<PackageVersion Include="NSubstitute.Analyzers.CSharp" Version="1.0.17" />
32-
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
33-
<PackageVersion Include="MSTest.TestFramework" Version="$(MSTestVersion)" />
34-
<PackageVersion Include="MSTest.TestAdapter" Version="$(MSTestVersion)" />
26+
<PackageVersion Include="Aspire.Hosting.AppHost" Version="$(AspireVersion)"/>
27+
<PackageVersion Include="Aspire.Hosting.Testing" Version="$(AspireVersion)"/>
28+
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.4"/>
29+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0"/>
30+
<PackageVersion Include="xunit.v3" Version="2.0.1"/>
31+
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2"/>
32+
<PackageVersion Include="Meziantou.Extensions.Logging.Xunit.v3" Version="1.1.2"/>
33+
<PackageVersion Include="NSubstitute" Version="5.3.0"/>
34+
<PackageVersion Include="NSubstitute.Analyzers.CSharp" Version="1.0.17"/>
35+
<PackageVersion Include="coverlet.collector" Version="6.0.4"/>
3536
<!-- Examples only -->
36-
<PackageVersion Include="dotNetRdf" Version="3.3.2" />
37-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.4" />
38-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.4" />
39-
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.4" />
40-
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.4" />
41-
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.4" />
42-
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.4" />
37+
<PackageVersion Include="dotNetRdf" Version="3.3.2"/>
38+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.4"/>
39+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.4"/>
40+
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.4"/>
41+
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.4"/>
42+
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.4"/>
43+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.4"/>
4344
</ItemGroup>
44-
</Project>
45+
</Project>

OSLC4Net_SDK/Examples/Oslc4NetExamples.Client/Program.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@
2525

2626
string username = "%USERNAME%";
2727
string password = "%PASSWORD%";
28-
var oslcClient = OslcClient.ForBasicAuth(username, password);
28+
var oslcClient = OslcClient.ForBasicAuth(username, password,
29+
services.GetRequiredService<ILogger<OslcClient>>());
2930

3031
var resourceUri =
3132
$"{jazzCmBase}/resource/itemName/com.ibm.team.workitem.WorkItem/{workItemId}";
3233
OslcResponse<ChangeRequest> response = await oslcClient.GetResourceAsync<ChangeRequest>(resourceUri);
33-
if (response.Resource is not null)
34+
if (response.Resources?.SingleOrDefault() is not null)
3435
{
35-
var changeRequestResource = response.Resource;
36+
var changeRequestResource = response.Resources.Single();
3637
logger.LogInformation(
3738
"{shortTitle} {title}", changeRequestResource.GetShortTitle(),
3839
changeRequestResource.GetTitle());

OSLC4Net_SDK/OSLC4Net.Client/Exceptions/JazzAuthErrorException.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ public string getJazzUrl()
4343
{
4444
return jazzUrl;
4545
}
46-
}
46+
}

OSLC4Net_SDK/OSLC4Net.Client/Exceptions/JazzAuthFailedException.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ public string GetJazzUrl()
4141
{
4242
return jazzUrl;
4343
}
44-
}
44+
}

OSLC4Net_SDK/OSLC4Net.Client/Exceptions/MessageExtractor.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
*******************************************************************************/
1515

1616
using System.Resources;
17-
1817
using log4net;
19-
2018
using OSLC4Net.Client.Properties;
2119

2220
namespace OSLC4Net.Client.Exceptions;
@@ -37,7 +35,6 @@ public static class MessageExtractor
3735
/// <returns></returns>
3836
public static string GetMessage(string key, object[] args)
3937
{
40-
4138
try
4239
{
4340
var message = rm.GetString(key);
@@ -49,4 +46,4 @@ public static string GetMessage(string key, object[] args)
4946
return "???" + key + "???";
5047
}
5148
}
52-
}
49+
}

OSLC4Net_SDK/OSLC4Net.Client/Exceptions/OslcClientApplicationException.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ public OslcClientApplicationException(string messageKey, object[] args, Exceptio
2929
base(MessageExtractor.GetMessage(messageKey, args), e)
3030
{
3131
}
32-
}
32+
}

OSLC4Net_SDK/OSLC4Net.Client/Exceptions/ResourceNotFoundException.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ public string GetValue()
4141
{
4242
return value;
4343
}
44-
}
44+
}

OSLC4Net_SDK/OSLC4Net.Client/Exceptions/RootServicesException.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ public string GetJazzUrl()
3131
{
3232
return jazzUrl;
3333
}
34-
}
34+
}

OSLC4Net_SDK/OSLC4Net.Client/OSLC4Net.Client.csproj

+6-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<DocumentationFile>bin\Debug\OSLC4Net.Client.XML</DocumentationFile>
1212
</PropertyGroup>
1313
<ItemGroup>
14-
<None Include="../../README.md" Pack="true" PackagePath="" />
14+
<None Include="../../README.md" Pack="true" PackagePath=""/>
1515
</ItemGroup>
1616
<ItemGroup>
1717
<Compile Update="Properties\Resources.Designer.cs">
@@ -27,14 +27,15 @@
2727
</EmbeddedResource>
2828
</ItemGroup>
2929
<ItemGroup>
30-
<ProjectReference Include="..\OSLC4Net.Core.Query\OSLC4Net.Core.Query.csproj" />
31-
<ProjectReference Include="..\OSLC4Net.Core\OSLC4Net.Core.csproj" />
32-
<ProjectReference Include="..\OSLC4Net.Core.DotNetRdfProvider\OSLC4Net.Core.DotNetRdfProvider.csproj" />
30+
<ProjectReference Include="..\OSLC4Net.Core.Query\OSLC4Net.Core.Query.csproj"/>
31+
<ProjectReference Include="..\OSLC4Net.Core\OSLC4Net.Core.csproj"/>
32+
<ProjectReference Include="..\OSLC4Net.Core.DotNetRdfProvider\OSLC4Net.Core.DotNetRdfProvider.csproj"/>
3333
</ItemGroup>
3434
<ItemGroup>
35-
<PackageReference Include="CommunityToolkit.Diagnostics" />
35+
<PackageReference Include="CommunityToolkit.Diagnostics"/>
3636
<PackageReference Include="dotNetRdf.Core"/>
3737
<PackageReference Include="Microsoft.AspNet.WebApi.Client"/>
3838
<PackageReference Include="log4net"/>
39+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions"/>
3940
</ItemGroup>
4041
</Project>

OSLC4Net_SDK/OSLC4Net.Client/Oslc/OSLCConstants.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ public static class OSLCConstants
8686
public const string TOTAL_COUNT_PROP = OSLC_V2 + "totalCount";
8787
public const string RESOURCE_TYPE_PROP = OSLC_V2 + "resourceType";
8888
public const string RESOURCE_SHAPE_PROP = OSLC_V2 + "resourceShape";
89+
8990
public const string DESCRIPTION_PROP = OSLC_V2 + "Description";
91+
9092
// OSLC CM 2.0
9193
public const string CM_CHANGE_REQUEST_TYPE = OSLC_CM_V2 + "ChangeRequest";
9294
public const string CM_CLOSE_DATE_PROP = OSLC_CM_V2 + "closeDate";
@@ -143,4 +145,4 @@ public static class OSLCConstants
143145
public const string DCTERMS_NAME = DCTERMS + "name";
144146
public const string DCTERMS_CREATED = DCTERMS + "created";
145147
public const string DCTERMS_MODIFIED = DCTERMS + "modified";
146-
}
148+
}

0 commit comments

Comments
 (0)