Skip to content

Commit

Permalink
Apply Rider rules
Browse files Browse the repository at this point in the history
  • Loading branch information
trejjam committed Feb 1, 2024
1 parent b860e16 commit 88a1309
Show file tree
Hide file tree
Showing 25 changed files with 743 additions and 667 deletions.
4 changes: 4 additions & 0 deletions nuget/helpers/lib/NuGetUpdater/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,7 @@ dotnet_naming_style.s_camelcase.required_prefix = s_
dotnet_naming_style.s_camelcase.required_suffix =
dotnet_naming_style.s_camelcase.word_separator =
dotnet_naming_style.s_camelcase.capitalization = camel_case

[NuGetUpdater.Core.Test/FrameworkChecker/SupportedFrameworkFacts.cs]
generated_code = true
disable_formatter = true

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,23 @@ public void EmptyProject_GetDependencies_ReturnsNoDependencies()
// no change made
[InlineData(
// language=csproj
@"<Project><ItemGroup><Reference><HintPath>path\to\file.dll</HintPath></Reference></ItemGroup></Project>",
@"<Project><ItemGroup><Reference><HintPath>path\to\file.dll</HintPath></Reference></ItemGroup></Project>",
// language=csproj
@"<Project><ItemGroup><Reference><HintPath>path\to\file.dll</HintPath></Reference></ItemGroup></Project>"
@"<Project><ItemGroup><Reference><HintPath>path\to\file.dll</HintPath></Reference></ItemGroup></Project>"
)]
// change from `/` to `\`
[InlineData(
// language=csproj
"<Project><ItemGroup><Reference><HintPath>path/to/file.dll</HintPath></Reference></ItemGroup></Project>",
"<Project><ItemGroup><Reference><HintPath>path/to/file.dll</HintPath></Reference></ItemGroup></Project>",
// language=csproj
@"<Project><ItemGroup><Reference><HintPath>path\to\file.dll</HintPath></Reference></ItemGroup></Project>"
@"<Project><ItemGroup><Reference><HintPath>path\to\file.dll</HintPath></Reference></ItemGroup></Project>"
)]
// multiple changes made
[InlineData(
// language=csproj
"<Project><ItemGroup><Reference><HintPath>path1/to1/file1.dll</HintPath></Reference><Reference><HintPath>path2/to2/file2.dll</HintPath></Reference></ItemGroup></Project>",
"<Project><ItemGroup><Reference><HintPath>path1/to1/file1.dll</HintPath></Reference><Reference><HintPath>path2/to2/file2.dll</HintPath></Reference></ItemGroup></Project>",
// language=csproj
@"<Project><ItemGroup><Reference><HintPath>path1\to1\file1.dll</HintPath></Reference><Reference><HintPath>path2\to2\file2.dll</HintPath></Reference></ItemGroup></Project>"
@"<Project><ItemGroup><Reference><HintPath>path1\to1\file1.dll</HintPath></Reference><Reference><HintPath>path2\to2\file2.dll</HintPath></Reference></ItemGroup></Project>"
)]
public void ReferenceHintPathsCanBeNormalized(string originalXml, string expectedXml)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,24 @@ public class SupportedFrameworksFacts
private static readonly NuGetFramework WinRt = new NuGetFramework(FrameworkIdentifiers.WinRT, EmptyVersion);

// See: https://docs.microsoft.com/en-us/dotnet/standard/frameworks#deprecated-target-frameworks
private readonly HashSet<NuGetFramework> DeprecatedFrameworks =
[
AspNet,
AspNet50,
AspNetCore,
AspNetCore50,
Dnx,
Dnx45,
Dnx451,
Dnx452,
DnxCore,
DnxCore50,
DotNet,
DotNet50,
DotNet51,
DotNet52,
DotNet53,
DotNet54,
DotNet55,
DotNet56,
NetCore50,
Win,
Win8,
Win81,
Win10,
WinRt
];
private readonly HashSet<NuGetFramework> DeprecatedFrameworks = new HashSet<NuGetFramework>() {
AspNet, AspNet50, AspNetCore, AspNetCore50,
Dnx, Dnx45, Dnx451, Dnx452, DnxCore, DnxCore50,
DotNet, DotNet50, DotNet51, DotNet52, DotNet53, DotNet54, DotNet55, DotNet56,
NetCore50,
Win, Win8, Win81, Win10,
WinRt
};
// The following frameworks were included in NuGet.Client code but they were not official framework releases.
private readonly HashSet<NuGetFramework> UnofficialFrameworks = [
NetStandard17,
NetStandardApp15,
];
private readonly HashSet<NuGetFramework> UnofficialFrameworks = new HashSet<NuGetFramework>()
{
NetStandard17, NetStandardApp15
};

[Fact]
public void SupportedFrameworksContainsCommonFrameworksWithNoDeprecatedFrameworks()
{
var fields = typeof(CommonFrameworks)
var fields = typeof(FrameworkConstants.CommonFrameworks)
.GetFields()
.Where(f => f.FieldType == typeof(NuGetFramework))
.ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task UpdateSingleDependencyInDirsProj()
// initial
projectContents: """
<Project Sdk="Microsoft.Build.NoTargets">

<ItemGroup>
<ProjectReference Include="src/test-project.csproj" />
</ItemGroup>
Expand All @@ -34,22 +34,22 @@ public async Task UpdateSingleDependencyInDirsProj()
additionalFiles:
[
("src/test-project.csproj",
"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>
</Project>
""")
"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>
</Project>
""")
],
// expected
expectedProjectContents: """
<Project Sdk="Microsoft.Build.NoTargets">

<ItemGroup>
<ProjectReference Include="src/test-project.csproj" />
</ItemGroup>
Expand All @@ -59,17 +59,17 @@ public async Task UpdateSingleDependencyInDirsProj()
additionalFilesExpected:
[
("src/test-project.csproj",
"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>
""")
"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>
""")
]);
}

Expand Down Expand Up @@ -101,7 +101,7 @@ public async Task UpdateSingleDependencyInNestedDirsProj()
// initial
projectContents: """
<Project Sdk="Microsoft.Build.NoTargets">

<ItemGroup>
<ProjectReference Include="src/dirs.proj" />
</ItemGroup>
Expand All @@ -111,32 +111,32 @@ public async Task UpdateSingleDependencyInNestedDirsProj()
additionalFiles:
[
("src/dirs.proj",
"""
<Project Sdk="Microsoft.Build.NoTargets">

<ItemGroup>
<ProjectReference Include="test-project/test-project.csproj" />
</ItemGroup>

</Project>
"""),
"""
<Project Sdk="Microsoft.Build.NoTargets">
<ItemGroup>
<ProjectReference Include="test-project/test-project.csproj" />
</ItemGroup>

</Project>
"""),
("src/test-project/test-project.csproj",
"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>
</Project>
""")
"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>
</Project>
""")
],
// expected
expectedProjectContents: """
<Project Sdk="Microsoft.Build.NoTargets">

<ItemGroup>
<ProjectReference Include="src/dirs.proj" />
</ItemGroup>
Expand All @@ -146,27 +146,27 @@ public async Task UpdateSingleDependencyInNestedDirsProj()
additionalFilesExpected:
[
("src/dirs.proj",
"""
<Project Sdk="Microsoft.Build.NoTargets">

<ItemGroup>
<ProjectReference Include="test-project/test-project.csproj" />
</ItemGroup>

</Project>
"""),
"""
<Project Sdk="Microsoft.Build.NoTargets">
<ItemGroup>
<ProjectReference Include="test-project/test-project.csproj" />
</ItemGroup>

</Project>
"""),
("src/test-project/test-project.csproj",
"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>
""")
"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>
""")
]);
}

Expand All @@ -180,8 +180,8 @@ public async Task UpdateSingleDependencyInNestedDirsProj()
(string Path, string Content)[]? additionalFiles = null,
(string Path, string Content)[]? additionalFilesExpected = null)
{
additionalFiles ??= Array.Empty<(string Path, string Content)>();
additionalFilesExpected ??= Array.Empty<(string Path, string Content)>();
additionalFiles ??= [];
additionalFilesExpected ??= [];

var projectName = "dirs";
var projectFileName = $"{projectName}.proj";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ public abstract class UpdateWorkerTestBase
string projectContents,
bool isTransitive = false,
(string Path, string Content)[]? additionalFiles = null,
string projectFilePath = "test-project.csproj")
=> TestUpdateForProject(dependencyName, oldVersion, newVersion, (projectFilePath, projectContents), expectedProjectContents: projectContents, isTransitive, additionalFiles, additionalFilesExpected: additionalFiles);
string projectFilePath = "test-project.csproj"
) => TestUpdateForProject(
dependencyName,
oldVersion,
newVersion,
(projectFilePath, projectContents),
expectedProjectContents: projectContents,
isTransitive,
additionalFiles,
additionalFilesExpected: additionalFiles);

protected static Task TestUpdateForProject(
string dependencyName,
Expand All @@ -29,11 +37,16 @@ public abstract class UpdateWorkerTestBase
bool isTransitive = false,
(string Path, string Content)[]? additionalFiles = null,
(string Path, string Content)[]? additionalFilesExpected = null,
string projectFilePath = "test-project.csproj")
{
var projectFile = (Path: projectFilePath, Content: projectContents);
return TestUpdateForProject(dependencyName, oldVersion, newVersion, projectFile, expectedProjectContents, isTransitive, additionalFiles, additionalFilesExpected);
}
string projectFilePath = "test-project.csproj"
) => TestUpdateForProject(
dependencyName,
oldVersion,
newVersion,
(Path: projectFilePath, Content: projectContents),
expectedProjectContents,
isTransitive,
additionalFiles,
additionalFilesExpected);

protected static async Task TestUpdateForProject(
string dependencyName,
Expand All @@ -45,8 +58,8 @@ public abstract class UpdateWorkerTestBase
(string Path, string Content)[]? additionalFiles = null,
(string Path, string Content)[]? additionalFilesExpected = null)
{
additionalFiles ??= Array.Empty<(string Path, string Content)>();
additionalFilesExpected ??= Array.Empty<(string Path, string Content)>();
additionalFiles ??= [];
additionalFilesExpected ??= [];

var projectFilePath = projectFile.Path;
var projectName = Path.GetFileNameWithoutExtension(projectFilePath);
Expand Down

0 comments on commit 88a1309

Please sign in to comment.