Skip to content

Commit e954c18

Browse files
authored
Update Refit.Tests to use net 4.8 (#1953)
* Update Refit.Tests to use net 4.8 * Update Interface Stub Generator * Update ApiExtensions.cs * Update to fix build issues when updating Packages * Update ci-build.yml * Update Packages * Update Packages * Update in attempt to build * Change Signing
1 parent c68f581 commit e954c18

24 files changed

+187
-139
lines changed

.github/workflows/ci-build.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ jobs:
1313
build:
1414
uses: reactiveui/actions-common/.github/workflows/workflow-common-setup-and-build.yml@main
1515
with:
16-
configuration: Release
1716
productNamespacePrefix: "Refit"
1817
srcFolder: "./"
19-
installWorkflows: false
18+
installWorkflows: true

Directory.Build.props

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
<ImplicitUsings>true</ImplicitUsings>
2323
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2424
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)buildtask.snk</AssemblyOriginatorKeyFile>
25-
<SignAssembly>true</SignAssembly>
26-
<RefitTargets>net462;netstandard2.0;net6.0;net8.0</RefitTargets>
25+
<!--<SignAssembly>true</SignAssembly>-->
26+
<RefitTargets>net462;netstandard2.0;net8.0;net9.0</RefitTargets>
2727
<NoWarn>IDE0040;CA1054;CA1510</NoWarn>
2828
</PropertyGroup>
2929

@@ -43,7 +43,7 @@
4343

4444
<ItemGroup>
4545
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
46-
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.146" PrivateAssets="all" />
46+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.7.115" PrivateAssets="all" />
4747
</ItemGroup>
4848

4949
<Target Name="AddCommitHashToAssemblyAttributes" BeforeTargets="GetAssemblyAttributes">

InterfaceStubGenerator.Shared/UniqueNameBuilder.cs

+25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
namespace Refit.Generator;
22

3+
// <Summary>
4+
// UniqueNameBuilder.
5+
// </Summary>
36
public class UniqueNameBuilder()
47
{
58
private readonly HashSet<string> _usedNames = new(StringComparer.Ordinal);
@@ -11,10 +14,23 @@ private UniqueNameBuilder(UniqueNameBuilder parentScope)
1114
_parentScope = parentScope;
1215
}
1316

17+
/// <summary>
18+
/// Reserve a name.
19+
/// </summary>
20+
/// <param name="name"></param>
1421
public void Reserve(string name) => _usedNames.Add(name);
1522

23+
/// <summary>
24+
/// Create a new scope.
25+
/// </summary>
26+
/// <returns>Unique Name Builder.</returns>
1627
public UniqueNameBuilder NewScope() => new(this);
1728

29+
/// <summary>
30+
/// Generate a unique name.
31+
/// </summary>
32+
/// <param name="name">THe name.</param>
33+
/// <returns></returns>
1834
public string New(string name)
1935
{
2036
var i = 0;
@@ -30,8 +46,17 @@ public string New(string name)
3046
return uniqueName;
3147
}
3248

49+
/// <summary>
50+
/// Reserve names.
51+
/// </summary>
52+
/// <param name="names">The name.</param>
3353
public void Reserve(IEnumerable<string> names)
3454
{
55+
if (names == null)
56+
{
57+
return;
58+
}
59+
3560
foreach (var name in names)
3661
{
3762
_usedNames.Add(name);

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) .NET Foundation and Contributors
3+
Copyright (c) ReactiveUI 2012 - 2025
44

55
All rights reserved.
66

Refit.Benchmarks/Refit.Benchmarks.csproj

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<Import Project="..\Refit\targets\refit.props" />
44

55
<PropertyGroup>
66
<OutputType>Exe</OutputType>
7-
<TargetFrameworks>net6.0</TargetFrameworks>
7+
<TargetFrameworks>net8.0</TargetFrameworks>
88
<IsPackable>false</IsPackable>
99
<NoWarn>$(NoWarn);CS1591</NoWarn>
1010
</PropertyGroup>
@@ -18,6 +18,8 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21+
<PackageReference Include="System.Net.Http" Version="4.3.4" />
22+
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
2123
<PackageReference Include="AutoFixture" Version="4.18.1" />
2224
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
2325
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.12.0-3.24523.4" />
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,54 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<Import Project="..\Refit\targets\refit.props" />
3+
<Import Project="..\Refit\targets\refit.props" />
44

5-
<PropertyGroup>
6-
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
7-
<ImplicitUsings>enable</ImplicitUsings>
8-
<Nullable>enable</Nullable>
5+
<PropertyGroup>
6+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
99

10-
<IsPackable>false</IsPackable>
11-
<IsTestProject>true</IsTestProject>
12-
<NoWarn>$(NoWarn);CS1591;CA1819;CA2000;CA2007;CA1056;CA1707;CA1861;xUnit1031</NoWarn>
13-
</PropertyGroup>
10+
<IsPackable>false</IsPackable>
11+
<IsTestProject>true</IsTestProject>
12+
<NoWarn>$(NoWarn);CS1591;CA1819;CA2000;CA2007;CA1056;CA1707;CA1861;xUnit1031</NoWarn>
13+
</PropertyGroup>
14+
<ItemGroup Condition="$(TargetFramework.StartsWith('net9.0'))">
15+
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="9.0.3" />
16+
</ItemGroup>
1417

15-
<ItemGroup>
16-
<PackageReference Include="coverlet.collector" Version="6.0.2" />
17-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
18-
<PackageReference Include="System.Formats.Asn1" Version="8.0.1" />
19-
<PackageReference Include="xunit" Version="2.9.2" />
20-
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
21-
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
22-
<PackageReference Include="Verify.DiffPlex" Version="3.1.2" />
23-
<PackageReference Include="Verify.SourceGenerators" Version="2.5.0" />
24-
<PackageReference Include="Verify.Xunit" Version="27.1.0" />
25-
<PackageReference Include="System.Reactive" Version="6.0.1" />
26-
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
27-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0" />
28-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing" Version="1.1.2" />
29-
<ProjectReference Include="..\Refit.Newtonsoft.Json\Refit.Newtonsoft.Json.csproj" />
30-
<ProjectReference Include="..\Refit.Xml\Refit.Xml.csproj" />
31-
<ProjectReference Include="..\InterfaceStubGenerator.Roslyn38\InterfaceStubGenerator.Roslyn38.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="true" />
32-
<ProjectReference Include="..\InterfaceStubGenerator.Roslyn41\InterfaceStubGenerator.Roslyn41.csproj" />
33-
<ProjectReference Include="..\Refit\Refit.csproj" />
34-
</ItemGroup>
18+
<ItemGroup Condition="$(TargetFramework.StartsWith('net8.0'))">
19+
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="8.0.14" />
20+
</ItemGroup>
21+
<ItemGroup>
22+
<PackageReference Include="System.Formats.Asn1" Version="9.0.3" />
23+
<PackageReference Include="coverlet.collector" Version="6.0.4" />
24+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
25+
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
26+
<PackageReference Include="xunit" Version="2.9.3" />
27+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2" />
28+
<PackageReference Include="System.Collections.Immutable" Version="9.0.3" />
29+
<PackageReference Include="Verify.DiffPlex" Version="3.1.2" />
30+
<PackageReference Include="Verify.SourceGenerators" Version="2.5.0" />
31+
<PackageReference Include="Verify.Xunit" Version="28.16.0" />
32+
<PackageReference Include="System.Reactive" Version="6.0.1" />
33+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0" />
34+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing" Version="1.1.2" />
35+
<ProjectReference Include="..\Refit.Newtonsoft.Json\Refit.Newtonsoft.Json.csproj" />
36+
<ProjectReference Include="..\Refit.Xml\Refit.Xml.csproj" />
37+
<ProjectReference Include="..\InterfaceStubGenerator.Roslyn38\InterfaceStubGenerator.Roslyn38.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="true" />
38+
<ProjectReference Include="..\InterfaceStubGenerator.Roslyn41\InterfaceStubGenerator.Roslyn41.csproj" />
39+
<ProjectReference Include="..\Refit\Refit.csproj" />
40+
</ItemGroup>
3541

36-
<ItemGroup>
37-
<None Include="..\Refit.GeneratorTests\_snapshots\**">
38-
<Link>%(RecursiveDir)\resources\%(Filename)%(Extension)</Link>
39-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
40-
</None>
41-
<Using Include="Xunit" />
42-
</ItemGroup>
42+
<ItemGroup>
43+
<None Include="..\Refit.GeneratorTests\_snapshots\**">
44+
<Link>%(RecursiveDir)\resources\%(Filename)%(Extension)</Link>
45+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
46+
</None>
47+
<Using Include="Xunit" />
48+
</ItemGroup>
49+
50+
<ItemGroup>
51+
<Folder Include="_snapshots\" />
52+
</ItemGroup>
4353

44-
<ItemGroup>
45-
<Folder Include="_snapshots\" />
46-
</ItemGroup>
4754
</Project>

Refit.HttpClientFactory/Refit.HttpClientFactory.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<ItemGroup>
1111
<ProjectReference Include="..\Refit\Refit.csproj" PrivateAssets="Analyzers" />
12-
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
12+
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.3" />
1313
</ItemGroup>
1414

1515
</Project>

Refit.Tests/API/ApiApprovalTests.Refit.DotNet8_0.verified.txt

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Refit.HttpClientFactory, PublicKey=00240000048000009400000006020000002400005253413100040000010001009dc017250415a0d51fddb74de84257c388028f04893673ca5c8f9e7145aea2b11443cb49dd79386d2255179a79ec516466b621f77e43386e711b775f77bb0e4b217f8c208c054e5f515ae33ee76bac1b56cdc20e1c151cf026a9b7f8362f1963825e546e16b360dfc63fe670403c9d6152c24491dd5dfb9ff68fe102ef3e1aed")]
2-
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Refit.Newtonsoft.Json, PublicKey=00240000048000009400000006020000002400005253413100040000010001009dc017250415a0d51fddb74de84257c388028f04893673ca5c8f9e7145aea2b11443cb49dd79386d2255179a79ec516466b621f77e43386e711b775f77bb0e4b217f8c208c054e5f515ae33ee76bac1b56cdc20e1c151cf026a9b7f8362f1963825e546e16b360dfc63fe670403c9d6152c24491dd5dfb9ff68fe102ef3e1aed")]
3-
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Refit.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001009dc017250415a0d51fddb74de84257c388028f04893673ca5c8f9e7145aea2b11443cb49dd79386d2255179a79ec516466b621f77e43386e711b775f77bb0e4b217f8c208c054e5f515ae33ee76bac1b56cdc20e1c151cf026a9b7f8362f1963825e546e16b360dfc63fe670403c9d6152c24491dd5dfb9ff68fe102ef3e1aed")]
4-
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Refit.Xml, PublicKey=00240000048000009400000006020000002400005253413100040000010001009dc017250415a0d51fddb74de84257c388028f04893673ca5c8f9e7145aea2b11443cb49dd79386d2255179a79ec516466b621f77e43386e711b775f77bb0e4b217f8c208c054e5f515ae33ee76bac1b56cdc20e1c151cf026a9b7f8362f1963825e546e16b360dfc63fe670403c9d6152c24491dd5dfb9ff68fe102ef3e1aed")]
1+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Refit.HttpClientFactory")]
2+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Refit.Newtonsoft.Json")]
3+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Refit.Tests")]
4+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Refit.Xml")]
55
[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName=".NET 8.0")]
66
namespace Refit
77
{
88
[System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Parameter)]
99
public class AliasAsAttribute : System.Attribute
1010
{
1111
public AliasAsAttribute(string name) { }
12-
public string Name { get; set; }
12+
public string Name { get; protected set; }
1313
}
1414
[System.Serializable]
1515
public class ApiException : System.Exception
@@ -66,7 +66,7 @@ namespace Refit
6666
public class AttachmentNameAttribute : System.Attribute
6767
{
6868
public AttachmentNameAttribute(string name) { }
69-
public string Name { get; set; }
69+
public string Name { get; protected set; }
7070
}
7171
[System.AttributeUsage(System.AttributeTargets.Parameter)]
7272
public class AuthorizeAttribute : System.Attribute
@@ -179,7 +179,7 @@ namespace Refit
179179
{
180180
protected HttpMethodAttribute(string path) { }
181181
public abstract System.Net.Http.HttpMethod Method { get; }
182-
public virtual string Path { get; set; }
182+
public virtual string Path { get; protected set; }
183183
}
184184
public static class HttpRequestMessageOptions
185185
{
@@ -334,10 +334,10 @@ namespace Refit
334334
public QueryAttribute(string delimiter, string prefix) { }
335335
public QueryAttribute(string delimiter, string prefix, string format) { }
336336
public Refit.CollectionFormat CollectionFormat { get; set; }
337-
public string Delimiter { get; set; }
337+
public string Delimiter { get; protected set; }
338338
public string? Format { get; set; }
339339
public bool IsCollectionFormatSpecified { get; }
340-
public string? Prefix { get; set; }
340+
public string? Prefix { get; protected set; }
341341
}
342342
[System.AttributeUsage(System.AttributeTargets.Method)]
343343
public class QueryUriFormatAttribute : System.Attribute
@@ -428,7 +428,7 @@ namespace Refit
428428
[System.Serializable]
429429
public class ValidationApiException : Refit.ApiException
430430
{
431-
public Refit.ProblemDetails? Content { get; }
431+
public new Refit.ProblemDetails? Content { get; }
432432
public static Refit.ValidationApiException Create(Refit.ApiException exception) { }
433433
}
434434
}

Refit.Tests/API/ApiApprovalTests.Refit.DotNet6_0.verified.txt Refit.Tests/API/ApiApprovalTests.Refit.DotNet9_0.verified.txt

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Refit.HttpClientFactory, PublicKey=00240000048000009400000006020000002400005253413100040000010001009dc017250415a0d51fddb74de84257c388028f04893673ca5c8f9e7145aea2b11443cb49dd79386d2255179a79ec516466b621f77e43386e711b775f77bb0e4b217f8c208c054e5f515ae33ee76bac1b56cdc20e1c151cf026a9b7f8362f1963825e546e16b360dfc63fe670403c9d6152c24491dd5dfb9ff68fe102ef3e1aed")]
2-
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Refit.Newtonsoft.Json, PublicKey=00240000048000009400000006020000002400005253413100040000010001009dc017250415a0d51fddb74de84257c388028f04893673ca5c8f9e7145aea2b11443cb49dd79386d2255179a79ec516466b621f77e43386e711b775f77bb0e4b217f8c208c054e5f515ae33ee76bac1b56cdc20e1c151cf026a9b7f8362f1963825e546e16b360dfc63fe670403c9d6152c24491dd5dfb9ff68fe102ef3e1aed")]
3-
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Refit.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001009dc017250415a0d51fddb74de84257c388028f04893673ca5c8f9e7145aea2b11443cb49dd79386d2255179a79ec516466b621f77e43386e711b775f77bb0e4b217f8c208c054e5f515ae33ee76bac1b56cdc20e1c151cf026a9b7f8362f1963825e546e16b360dfc63fe670403c9d6152c24491dd5dfb9ff68fe102ef3e1aed")]
4-
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Refit.Xml, PublicKey=00240000048000009400000006020000002400005253413100040000010001009dc017250415a0d51fddb74de84257c388028f04893673ca5c8f9e7145aea2b11443cb49dd79386d2255179a79ec516466b621f77e43386e711b775f77bb0e4b217f8c208c054e5f515ae33ee76bac1b56cdc20e1c151cf026a9b7f8362f1963825e546e16b360dfc63fe670403c9d6152c24491dd5dfb9ff68fe102ef3e1aed")]
5-
[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName=".NET 6.0")]
1+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Refit.HttpClientFactory")]
2+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Refit.Newtonsoft.Json")]
3+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Refit.Tests")]
4+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Refit.Xml")]
5+
[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v9.0", FrameworkDisplayName=".NET 9.0")]
66
namespace Refit
77
{
88
[System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Parameter)]
99
public class AliasAsAttribute : System.Attribute
1010
{
1111
public AliasAsAttribute(string name) { }
12-
public string Name { get; set; }
12+
public string Name { get; protected set; }
1313
}
1414
[System.Serializable]
1515
public class ApiException : System.Exception
@@ -66,7 +66,7 @@ namespace Refit
6666
public class AttachmentNameAttribute : System.Attribute
6767
{
6868
public AttachmentNameAttribute(string name) { }
69-
public string Name { get; set; }
69+
public string Name { get; protected set; }
7070
}
7171
[System.AttributeUsage(System.AttributeTargets.Parameter)]
7272
public class AuthorizeAttribute : System.Attribute
@@ -179,7 +179,7 @@ namespace Refit
179179
{
180180
protected HttpMethodAttribute(string path) { }
181181
public abstract System.Net.Http.HttpMethod Method { get; }
182-
public virtual string Path { get; set; }
182+
public virtual string Path { get; protected set; }
183183
}
184184
public static class HttpRequestMessageOptions
185185
{
@@ -334,10 +334,10 @@ namespace Refit
334334
public QueryAttribute(string delimiter, string prefix) { }
335335
public QueryAttribute(string delimiter, string prefix, string format) { }
336336
public Refit.CollectionFormat CollectionFormat { get; set; }
337-
public string Delimiter { get; set; }
337+
public string Delimiter { get; protected set; }
338338
public string? Format { get; set; }
339339
public bool IsCollectionFormatSpecified { get; }
340-
public string? Prefix { get; set; }
340+
public string? Prefix { get; protected set; }
341341
}
342342
[System.AttributeUsage(System.AttributeTargets.Method)]
343343
public class QueryUriFormatAttribute : System.Attribute
@@ -428,7 +428,7 @@ namespace Refit
428428
[System.Serializable]
429429
public class ValidationApiException : Refit.ApiException
430430
{
431-
public Refit.ProblemDetails? Content { get; }
431+
public new Refit.ProblemDetails? Content { get; }
432432
public static Refit.ValidationApiException Create(Refit.ApiException exception) { }
433433
}
434434
}

Refit.Tests/API/ApiApprovalTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// The .NET Foundation licenses this file to you under the MIT license.
44
// See the LICENSE file in the project root for full license information.
55

6-
#if !NET462
6+
#if !NET48
77
using System.Diagnostics.CodeAnalysis;
88

99
namespace Refit.Tests.API;

Refit.Tests/API/ApiExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// The .NET Foundation licenses this file to you under the MIT license.
44
// See the LICENSE file in the project root for full license information.
55

6-
#if !NET462
6+
#if !NET48
77
using System.Diagnostics.CodeAnalysis;
88
using System.Reflection;
99
using System.Runtime.CompilerServices;

0 commit comments

Comments
 (0)