Skip to content

Commit

Permalink
housekeeping: Update Targets, Fix build, Update relevant packages (#1488
Browse files Browse the repository at this point in the history
)

* Update Targets, Fix build, Update relevant packages

* Fix newly added tests from merge

---------

Co-authored-by: Glenn <5834289+glennawatson@users.noreply.github.com>
  • Loading branch information
ChrisPulman and glennawatson committed Apr 12, 2023
1 parent e83f7e2 commit 098c4e3
Show file tree
Hide file tree
Showing 17 changed files with 61 additions and 66 deletions.
17 changes: 9 additions & 8 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project>

<Project>
<PropertyGroup>
<MinClientVersion>2.12</MinClientVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -10,6 +9,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/reactiveui/refit</PackageProjectUrl>
<PackageIcon>refit_logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<DefaultLanguage>en-US</DefaultLanguage>
<Description>The automatic type-safe REST library for Xamarin and .NET</Description>
<NoPackageAnalysis>true</NoPackageAnalysis>
Expand All @@ -31,16 +31,18 @@
</PropertyGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)refit_logo.png" Pack="true" PackagePath="\" Visible="false" />
<None Include="$(MSBuildThisFileDirectory)refit_logo.png" Pack="true" PackagePath="\" Visible="false" />
<None Include="$(MSBuildThisFileDirectory)LICENSE" Pack="true" PackagePath="LICENSE" />
<None Include="$(MSBuildThisFileDirectory)README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup Condition="'$(IsTestProject)' != 'true'">
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.0.64" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.5.22" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.255" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.5.119" PrivateAssets="all" />
</ItemGroup>

<Target Name="AddCommitHashToAssemblyAttributes" BeforeTargets="GetAssemblyAttributes">
Expand All @@ -51,5 +53,4 @@
</AssemblyAttribute>
</ItemGroup>
</Target>

</Project>
</Project>
8 changes: 4 additions & 4 deletions Refit.Benchmarks/Refit.Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

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

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -16,8 +16,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.17.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.0" />
<PackageReference Include="AutoFixture" Version="4.18.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 2 additions & 10 deletions Refit.HttpClientFactory/Refit.HttpClientFactory.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@
<PropertyGroup>
<Product>Refit HTTP Client Factory Extensions</Product>
<Description>Refit HTTP Client Factory Extensions</Description>
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net462;net6.0;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Refit\Refit.csproj" PrivateAssets="Analyzers" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Update="Microsoft.Extensions.Http" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Update="Microsoft.Extensions.Http" Version="3.1.11" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
</ItemGroup>

</Project>
8 changes: 4 additions & 4 deletions Refit.Newtonsoft.Json/Refit.Newtonsoft.Json.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Product>Refit Serializer for Newtonsoft.Json ($(TargetFramework))</Product>
<Description>Refit Serializers for Newtonsoft.Json</Description>
<TargetFrameworks>net6.0;net5.0;netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net462;net6.0;net7.0</TargetFrameworks>
<GenerateDocumentationFile Condition=" '$(Configuration)' == 'Release' ">true</GenerateDocumentationFile>
<RootNamespace>Refit</RootNamespace>
<Nullable>enable</Nullable>
Expand All @@ -14,9 +14,9 @@

</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies"
Version="1.0.2"
Version="1.0.3"
PrivateAssets="All" />
<Reference Include="System.Web" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Refit.Tests/InterfaceStubGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static InterfaceStubGeneratorTests()
ReferenceAssemblies = ReferenceAssemblies.Net.Net60;
#else
ReferenceAssemblies = ReferenceAssemblies.Default
.AddPackages(ImmutableArray.Create(new PackageIdentity("System.Text.Json", "6.0.1")));
.AddPackages(ImmutableArray.Create(new PackageIdentity("System.Text.Json", "7.0.2")));
#endif

#if NET461
Expand Down
6 changes: 3 additions & 3 deletions Refit.Tests/MultipartTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,13 @@ public async Task MultipartUploadShouldWorkWithHeaderAndRequestProperty()
{
Assert.Equal(someHeader, message.Headers.Authorization.ToString());
#if NET5_0_OR_GREATER
Assert.Equal(2, message.Options.Count());
#if NET6_0_OR_GREATER
Assert.Equal(3, message.Options.Count());
Assert.Equal(someProperty, ((IDictionary<string, object>)message.Options)["SomeProperty"]);
#endif
#pragma warning disable CS0618 // Type or member is obsolete
Assert.Equal(2, message.Properties.Count);
Assert.Equal(3, message.Properties.Count);
Assert.Equal(someProperty, message.Properties["SomeProperty"]);
#pragma warning restore CS0618 // Type or member is obsolete
},
Expand Down
12 changes: 6 additions & 6 deletions Refit.Tests/Refit.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="..\Refit\targets\refit.props" />

<PropertyGroup>
<TargetFrameworks>net6.0;net462</TargetFrameworks>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<Deterministic>false</Deterministic> <!-- Some tests rely on CallerFilePath -->
</PropertyGroup>

Expand All @@ -12,14 +12,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.1.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="coverlet.collector" Version="3.2.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageReference Include="System.Reactive" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.XUnit" Version="1.1.1-beta1.22069.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.XUnit" Version="1.1.1" />
<PackageReference Include="RichardSzalay.MockHttp" Version="6.0.0" />
<ProjectReference Include="..\Refit.HttpClientFactory\Refit.HttpClientFactory.csproj" />
<ProjectReference Include="..\Refit.Newtonsoft.Json\Refit.Newtonsoft.Json.csproj" />
Expand Down
14 changes: 7 additions & 7 deletions Refit.Tests/RequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2109,7 +2109,7 @@ public void DynamicRequestPropertiesShouldBeInProperties(string interfaceMethodN
var factory = fixture.BuildRequestFactoryForMethod(interfaceMethodName);
var output = factory(new object[] { 6, someProperty });

#if NET5_0_OR_GREATER
#if NET6_0_OR_GREATER
Assert.NotEmpty(output.Options);
Assert.Equal(someProperty, ((IDictionary<string, object>)output.Options)["SomeProperty"]);
#endif
Expand All @@ -2129,7 +2129,7 @@ public void InterfaceTypeShouldBeInProperties()
var factory = fixture.BuildRequestFactoryForMethod(nameof(IContainAandB.Ping));
var output = factory(new object[] { });

#if NET5_0_OR_GREATER
#if NET6_0_OR_GREATER
Assert.NotEmpty(output.Options);
Assert.Equal(typeof(IContainAandB), ((IDictionary<string, object>)output.Options)[HttpRequestMessageOptions.InterfaceType]);
#endif
Expand All @@ -2149,7 +2149,7 @@ public void RestMethodInfoShouldBeInProperties()
var factory = fixture.BuildRequestFactoryForMethod(nameof(IContainAandB.Ping));
var output = factory(new object[] { });

#if NET5_0_OR_GREATER
#if NET6_0_OR_GREATER
Assert.NotEmpty(output.Options);
Assert.True(output.Options.TryGetValue(new HttpRequestOptionsKey<RestMethodInfo>(HttpRequestMessageOptions.RestMethodInfo), out var restMethodInfo));
#else
Expand All @@ -2170,7 +2170,7 @@ public void DynamicRequestPropertiesWithDefaultKeysShouldBeInProperties()
var factory = fixture.BuildRequestFactoryForMethod(nameof(IDummyHttpApi.FetchSomeStuffWithDynamicRequestPropertyWithoutKey));
var output = factory(new object[] { 6, someProperty, someOtherProperty });

#if NET5_0_OR_GREATER
#if NET6_0_OR_GREATER
Assert.NotEmpty(output.Options);
Assert.Equal(someProperty, ((IDictionary<string, object>)output.Options)["someValue"]);
Assert.Equal(someOtherProperty, ((IDictionary<string, object>)output.Options)["someOtherValue"]);
Expand All @@ -2193,13 +2193,13 @@ public void DynamicRequestPropertiesWithDuplicateKeyShouldOverwritePreviousPrope
var output = factory(new object[] { 6, someProperty, someOtherProperty });


#if NET5_0_OR_GREATER
Assert.Equal(2, output.Options.Count());
#if NET6_0_OR_GREATER
Assert.Equal(3, output.Options.Count());
Assert.Equal(someOtherProperty, ((IDictionary<string, object>)output.Options)["SomeProperty"]);
#endif

#pragma warning disable CS0618 // Type or member is obsolete
Assert.Equal(2, output.Properties.Count);
Assert.Equal(3, output.Properties.Count);
Assert.Equal(someOtherProperty, output.Properties["SomeProperty"]);
#pragma warning restore CS0618 // Type or member is obsolete
}
Expand Down
6 changes: 3 additions & 3 deletions Refit.Xml/Refit.Xml.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<PropertyGroup>
<Product>Refit Xml Serializer ($(TargetFramework))</Product>
<Description>Refit Serializers for Xml</Description>
<TargetFrameworks>net6.0;net5.0;netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net462;net6.0;net7.0</TargetFrameworks>
<GenerateDocumentationFile Condition=" '$(Configuration)' == 'Release' ">true</GenerateDocumentationFile>
<RootNamespace>Refit</RootNamespace>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies"
Version="1.0.2"
Version="1.0.3"
PrivateAssets="All" />
<Reference Include="System.Web" />
</ItemGroup>
Expand Down
14 changes: 8 additions & 6 deletions Refit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4F1C8991-7097-4471-A9A6-A72005AB594D}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
azure-pipelines.yml = azure-pipelines.yml
.github\workflows\ci-build.yml = .github\workflows\ci-build.yml
Directory.build.props = Directory.build.props
LICENSE = LICENSE
README.md = README.md
Refit.ruleset = Refit.ruleset
.github\workflows\release.yml = .github\workflows\release.yml
version.json = version.json
EndProjectSection
EndProject
Expand All @@ -34,11 +36,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Refit.Benchmarks", "Refit.Benchmarks\Refit.Benchmarks.csproj", "{ABD72A27-9C30-481A-8303-D8F825A8FD47}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
InterfaceStubGenerator.Shared\InterfaceStubGenerator.Shared.projitems*{72869789-0310-4916-9a41-20d16a01c1b8}*SharedItemsImports = 5
InterfaceStubGenerator.Shared\InterfaceStubGenerator.Shared.projitems*{a4b61169-3314-41db-8156-be9677c90c9f}*SharedItemsImports = 5
InterfaceStubGenerator.Shared\InterfaceStubGenerator.Shared.projitems*{b591423d-f92d-4e00-b0eb-615c9853506c}*SharedItemsImports = 13
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Expand Down Expand Up @@ -189,4 +186,9 @@ Global
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6E9C2873-AFF9-4D32-A784-1BA094814054}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
InterfaceStubGenerator.Shared\InterfaceStubGenerator.Shared.projitems*{72869789-0310-4916-9a41-20d16a01c1b8}*SharedItemsImports = 5
InterfaceStubGenerator.Shared\InterfaceStubGenerator.Shared.projitems*{a4b61169-3314-41db-8156-be9677c90c9f}*SharedItemsImports = 5
InterfaceStubGenerator.Shared\InterfaceStubGenerator.Shared.projitems*{b591423d-f92d-4e00-b0eb-615c9853506c}*SharedItemsImports = 13
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion Refit/ApiResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public ApiResponse(HttpResponseMessage response, T? content, RefitSettings setti

public HttpContentHeaders? ContentHeaders => response.Content?.Headers;

#if NET5_0_OR_GREATER
#if NET6_0_OR_GREATER
[MemberNotNullWhen(true, nameof(Content))]
[MemberNotNullWhen(true, nameof(ContentHeaders))]
[MemberNotNullWhen(false, nameof(Error))]
Expand Down
2 changes: 1 addition & 1 deletion Refit/Buffers/PooledBufferWriter.Stream.NETStandard21.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETSTANDARD2_1 || NET5_0_OR_GREATER
#if NETSTANDARD2_1 || NET6_0_OR_GREATER

using System;
using System.IO;
Expand Down
2 changes: 1 addition & 1 deletion Refit/Buffers/PooledBufferWriter.Stream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public override Task CopyToAsync(Stream destination, int bufferSize, Cancellatio

try
{
#if NETSTANDARD2_1 || NET5_0_OR_GREATER
#if NETSTANDARD2_1 || NET6_0_OR_GREATER
return CopyToInternalAsync(destination, cancellationToken);
#else
CopyTo(destination, bufferSize);
Expand Down
2 changes: 1 addition & 1 deletion Refit/HttpContentExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Refit
{
#if !NET5_0_OR_GREATER
#if !NET6_0_OR_GREATER
static class HttpContentExtensions
{
#pragma warning disable IDE0079 // Remove unnecessary suppression
Expand Down
8 changes: 4 additions & 4 deletions Refit/Refit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

<PropertyGroup>
<Product>Refit ($(TargetFramework))</Product>
<TargetFrameworks>net6.0;net5.0;netstandard2.0;netstandard2.1;net461</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net462;net6.0;net7.0</TargetFrameworks>
<GenerateDocumentationFile Condition=" '$(Configuration)' == 'Release' ">true</GenerateDocumentationFile>

<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Condition="'$(TargetFramework)' != 'net6.0'" Include="System.Text.Json" Version="6.0.1" />
<PackageReference Include="System.Net.Http.Json" Version="6.0.0" />
<PackageReference Include="System.Text.Json" Version="7.0.2" />
<PackageReference Include="System.Net.Http.Json" Version="7.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System.Web" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<ProjectReference Include="..\InterfaceStubGenerator.Roslyn38\InterfaceStubGenerator.Roslyn38.csproj" ReferenceOutputAssembly="false" />
Expand Down
8 changes: 4 additions & 4 deletions Refit/RequestBuilderImplementation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ void AddMultipartItem(MultipartFormDataContent multiPartContent, string fileName
}

// If obj is IEnumerable - format it accounting for Query attribute and CollectionFormat
if (!(obj is string) && obj is IEnumerable ienu && !(obj is IDictionary))
if (obj is not string && obj is IEnumerable ienu && obj is not IDictionary)
{
foreach (var value in ParseEnumerableQueryParameterValue(ienu, propertyInfo, propertyInfo.PropertyType, queryAttribute))
{
Expand Down Expand Up @@ -726,15 +726,15 @@ void AddMultipartItem(MultipartFormDataContent multiPartContent, string fileName
foreach (var property in propertiesToAdd)
{
#if NET5_0_OR_GREATER
#if NET6_0_OR_GREATER
ret.Options.Set(new HttpRequestOptionsKey<object?>(property.Key), property.Value);
#else
ret.Properties[property.Key] = property.Value;
#endif
}
// Always add the top-level type of the interface to the properties
#if NET5_0_OR_GREATER
#if NET6_0_OR_GREATER
ret.Options.Set(new HttpRequestOptionsKey<Type>(HttpRequestMessageOptions.InterfaceType), TargetType);
ret.Options.Set(new HttpRequestOptionsKey<RestMethodInfo>(HttpRequestMessageOptions.RestMethodInfo), restMethod);
#else
Expand Down Expand Up @@ -774,7 +774,7 @@ void AddMultipartItem(MultipartFormDataContent multiPartContent, string fileName

IEnumerable<KeyValuePair<string, string?>> ParseQueryParameter(object? param, ParameterInfo parameterInfo, string queryPath, QueryAttribute queryAttribute)
{
if (!(param is string) && param is IEnumerable paramValues)
if (param is not string && param is IEnumerable paramValues)
{
foreach (var value in ParseEnumerableQueryParameterValue(paramValues, parameterInfo, parameterInfo.ParameterType, queryAttribute))
{
Expand Down
4 changes: 2 additions & 2 deletions Refit/RestMethodInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ static void VerifyUrlPathIsSane(string relativePath)
}
var parameterType = isRoundTripping ? ParameterType.RoundTripping : ParameterType.Normal;
var restMethodParameterInfo = new RestMethodParameterInfo(name, paramValidationDict[name]) { Type = parameterType };
#if NETSTANDARD2_1 || NET5_0_OR_GREATER
#if NETSTANDARD2_1 || NET6_0_OR_GREATER
ret.TryAdd(parameterInfo.IndexOf(restMethodParameterInfo.ParameterInfo), restMethodParameterInfo);
#else
var idx = parameterInfo.IndexOf(restMethodParameterInfo.ParameterInfo);
Expand Down Expand Up @@ -269,7 +269,7 @@ static void VerifyUrlPathIsSane(string relativePath)
{
var restMethodParameterInfo = new RestMethodParameterInfo(true, property.Item1);
restMethodParameterInfo.ParameterProperties.Add(new RestMethodParameterProperty(name, property.Item2));
#if NETSTANDARD2_1 || NET5_0_OR_GREATER
#if NETSTANDARD2_1 || NET6_0_OR_GREATER
ret.TryAdd(parameterInfo.IndexOf(restMethodParameterInfo.ParameterInfo), restMethodParameterInfo);
#else
// Do the contains check
Expand Down

0 comments on commit 098c4e3

Please sign in to comment.