Skip to content

Commit

Permalink
Fixed centralized package versions
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyzimarev committed Sep 18, 2023
1 parent 121bf93 commit 4a40bcd
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 59 deletions.
4 changes: 4 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@
<PackageVersion Include="BenchmarkDotNet" Version="0.13.8"/>
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0"/>
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4"/>
<PackageVersion Include="Moq" Version="4.20.69"/>
<PackageVersion Include="RichardSzalay.MockHttp" Version="6.0.0"/>
<PackageVersion Include="System.Net.Http.Json" Version="7.0.1"/>
<PackageVersion Include="rest-mock-core" Version="0.7.12"/>
</ItemGroup>
</Project>
3 changes: 0 additions & 3 deletions gen/SourceGenerator/SourceGenerator.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>preview</LangVersion>
Expand All @@ -9,12 +8,10 @@
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\RestSharp.Serializers.NewtonsoftJson\RestSharp.Serializers.NewtonsoftJson.csproj" />
<ProjectReference Include="$(RepoRoot)\src\RestSharp\RestSharp.csproj" />
<ProjectReference Include="..\RestSharp.Tests.Shared\RestSharp.Tests.Shared.csproj" />
<ProjectReference Include="$(RepoRoot)\src\RestSharp.Serializers.NewtonsoftJson\RestSharp.Serializers.NewtonsoftJson.csproj"/>
<ProjectReference Include="$(RepoRoot)\src\RestSharp\RestSharp.csproj"/>
<ProjectReference Include="..\RestSharp.Tests.Shared\RestSharp.Tests.Shared.csproj"/>
</ItemGroup>
<ItemGroup>
<Compile Remove="NewtonsoftJson\IntegratedTests.cs" />
<Compile Remove="NewtonsoftJson\IntegratedTests.cs"/>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="rest-mock-core" Version="0.7.12" />
<Compile Include="NewtonsoftJson\IntegratedTests.cs" />
<PackageReference Include="rest-mock-core"/>
<Compile Include="NewtonsoftJson\IntegratedTests.cs"/>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="rest-mock-core" Version="0.7.12" />
<Compile Include="NewtonsoftJson\IntegratedTests.cs" />
<PackageReference Include="rest-mock-core"/>
<Compile Include="NewtonsoftJson\IntegratedTests.cs"/>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="rest-mock-core"/>
<Compile Include="NewtonsoftJson\IntegratedTests.cs"/>
</ItemGroup>
</Project>
9 changes: 3 additions & 6 deletions test/RestSharp.Tests.Shared/Fixtures/TestHttpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace RestSharp.Tests.Shared.Fixtures;

public delegate void HandlerAction(HttpListenerRequest request, HttpListenerResponse response, Dictionary<string, string> urlMap);

public class TestHttpServer : IDisposable {
readonly HttpListener _listener;
readonly List<TestRequestHandler> _requestHandlers;
Expand All @@ -12,12 +14,7 @@ public class TestHttpServer : IDisposable {

public int Port { get; }

public TestHttpServer(
int port,
string url,
Action<HttpListenerRequest, HttpListenerResponse, Dictionary<string, string>> handlerAction,
string hostName = "localhost"
)
public TestHttpServer(int port, string url, HandlerAction handlerAction, string hostName = "localhost")
: this(port, new List<TestRequestHandler> { new(url, handlerAction) }, hostName) { }

public TestHttpServer(int port, List<TestRequestHandler> handlers, string hostName = "localhost") {
Expand Down
21 changes: 7 additions & 14 deletions test/RestSharp.Tests.Shared/Fixtures/TestRequestHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Net;
using System.Text.RegularExpressions;

namespace RestSharp.Tests.Shared.Fixtures;
Expand All @@ -8,24 +7,19 @@ public class TestRequestHandler {

readonly List<string> _urlParameterNames = new();

public TestRequestHandler(
string url,
string httpMethod,
Action<HttpListenerRequest, HttpListenerResponse, Dictionary<string, string>> handlerAction
) {
public TestRequestHandler(string url, string httpMethod, HandlerAction handlerAction) {
Url = url;
HttpMethod = httpMethod;
HandlerAction = handlerAction;

_comparisonRegex = CreateComparisonRegex(url);
}

public TestRequestHandler(string url, Action<HttpListenerRequest, HttpListenerResponse, Dictionary<string, string>> handlerAction)
: this(url, null, handlerAction) { }
public TestRequestHandler(string url, HandlerAction handlerAction) : this(url, null, handlerAction) { }

string Url { get; }
string HttpMethod { get; }
internal Action<HttpListenerRequest, HttpListenerResponse, Dictionary<string, string>> HandlerAction { get; }
string Url { get; }
string HttpMethod { get; }
internal HandlerAction HandlerAction { get; }

Regex CreateComparisonRegex(string url) {
var regexString = Regex.Escape(url).Replace(@"\{", "{");
Expand Down Expand Up @@ -57,8 +51,7 @@ public bool TryMatchUrl(string rawUrl, string httpMethod, out Dictionary<string,

parameters = new Dictionary<string, string>();

for (var i = 0; i < _urlParameterNames.Count; i++)
parameters[_urlParameterNames[i]] = match.Groups[i + 1].Value;
for (var i = 0; i < _urlParameterNames.Count; i++) parameters[_urlParameterNames[i]] = match.Groups[i + 1].Value;
return true;
}
}
}
56 changes: 28 additions & 28 deletions test/RestSharp.Tests/RestSharp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="RichardSzalay.MockHttp" Version="6.0.0" />
<PackageReference Include="System.Net.Http.Json" Version="7.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\RestSharp\RestSharp.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="SampleData\4sq.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\bearertoken.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\datetimes.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\GenericWithList.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\iso8601datetimes.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\jsonarray.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\jsondictionary.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\jsondictionary_KeysType.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\jsondictionary_null.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\jsonenums.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\jsonenumtypes.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\jsonlists.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\newdatetimes.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\objectproperty.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\person.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\sojson.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\timespans.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\underscore_prefix.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Moq"/>
<PackageReference Include="RichardSzalay.MockHttp"/>
<PackageReference Include="System.Net.Http.Json"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\RestSharp\RestSharp.csproj"/>
</ItemGroup>
<ItemGroup>
<None Update="SampleData\4sq.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\bearertoken.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\datetimes.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\GenericWithList.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\iso8601datetimes.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\jsonarray.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\jsondictionary.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\jsondictionary_KeysType.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\jsondictionary_null.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\jsonenums.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\jsonenumtypes.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\jsonlists.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\newdatetimes.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\objectproperty.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\person.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\sojson.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\timespans.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\underscore_prefix.json" CopyToOutputDirectory="PreserveNewest"/>
</ItemGroup>
</Project>

0 comments on commit 4a40bcd

Please sign in to comment.