Skip to content

Commit

Permalink
Apply Rider rules
Browse files Browse the repository at this point in the history
  • Loading branch information
trejjam committed Jan 29, 2024
1 parent 6b52ef9 commit e6836e1
Show file tree
Hide file tree
Showing 33 changed files with 823 additions and 908 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ internal static Command GetCommand(Action<int> setExitCode)
{
Command command = new("framework-check", "Checks that a project's target frameworks are satisfied by the target frameworks supported by a package.")
{
ProjectTfmsOption,
PackageTfmsOption,
VerboseOption
ProjectTfmsOption, PackageTfmsOption, VerboseOption
};

command.TreatUnmatchedTokensAsErrors = true;
Expand Down
6 changes: 1 addition & 5 deletions nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ internal static async Task<int> Main(string[] args)
var exitCode = 0;
Action<int> setExitCode = code => exitCode = code;

var command = new RootCommand
{
FrameworkCheckCommand.GetCommand(setExitCode),
UpdateCommand.GetCommand(setExitCode),
};
var command = new RootCommand { FrameworkCheckCommand.GetCommand(setExitCode), UpdateCommand.GetCommand(setExitCode), };
command.TreatUnmatchedTokensAsErrors = true;

var result = await command.InvokeAsync(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ public class DotnetToolsJsonBuildFileTests
[Fact]
public void GetDependencies_ReturnsDependencies()
{
var expectedDependencies = new List<Dependency>
{
new("microsoft.botsay", "1.0.0", DependencyType.DotNetTool),
new("dotnetsay", "2.1.3", DependencyType.DotNetTool)
};
var expectedDependencies = new List<Dependency> { new("microsoft.botsay", "1.0.0", DependencyType.DotNetTool), new("dotnetsay", "2.1.3", DependencyType.DotNetTool) };

var buildFile = GetBuildFile();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ public void GlobalJson_NotJson_DoesNotThrow()
[Fact]
public void GlobalJson_GetDependencies_ReturnsDependencies()
{
var expectedDependencies = new List<Dependency>
{
new("My.Custom.Sdk", "5.0.0", DependencyType.MSBuildSdk),
new("My.Other.Sdk", "1.0.0-beta", DependencyType.MSBuildSdk)
};
var expectedDependencies = new List<Dependency> { new("My.Custom.Sdk", "5.0.0", DependencyType.MSBuildSdk), new("My.Other.Sdk", "1.0.0-beta", DependencyType.MSBuildSdk) };

var buildFile = GetBuildFile(GlobalJson);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ public void ProjectCsProj_GetDependencies_ReturnsDependencies()
[Fact]
public void ProjectCsProj_ReferencedProjectPaths_ReturnsPaths()
{
var expectedReferencedProjectPaths = new List<string>
{
"/Library/Library.csproj"
};
var expectedReferencedProjectPaths = new List<string> { "/Library/Library.csproj" };

var buildFile = GetBuildFile(ProjectCsProj, "Project.csproj");

Expand Down Expand Up @@ -107,11 +104,7 @@ public void DirectoryPackagesProps_GetDependencies_ReturnsDependencies()
[Fact]
public void DirectoryPackagesProps_Properties_ReturnsProperties()
{
var expectedProperties = new List<KeyValuePair<string, string>>
{
new("ManagePackageVersionsCentrally", "true"),
new("CentralPackageTransitivePinningEnabled", "true")
};
var expectedProperties = new List<KeyValuePair<string, string>> { new("ManagePackageVersionsCentrally", "true"), new("CentralPackageTransitivePinningEnabled", "true") };

var buildFile = GetBuildFile(DirectoryPackagesProps, "Directory.Packages.props");

Expand All @@ -134,16 +127,16 @@ public void EmptyProject_GetDependencies_ReturnsNoDependencies()

[Theory]
[InlineData( // no change made
@"<Project><ItemGroup><Reference><HintPath>path\to\file.dll</HintPath></Reference></ItemGroup></Project>",
@"<Project><ItemGroup><Reference><HintPath>path\to\file.dll</HintPath></Reference></ItemGroup></Project>"
@"<Project><ItemGroup><Reference><HintPath>path\to\file.dll</HintPath></Reference></ItemGroup></Project>",
@"<Project><ItemGroup><Reference><HintPath>path\to\file.dll</HintPath></Reference></ItemGroup></Project>"
)]
[InlineData( // change from `/` to `\`
"<Project><ItemGroup><Reference><HintPath>path/to/file.dll</HintPath></Reference></ItemGroup></Project>",
@"<Project><ItemGroup><Reference><HintPath>path\to\file.dll</HintPath></Reference></ItemGroup></Project>"
"<Project><ItemGroup><Reference><HintPath>path/to/file.dll</HintPath></Reference></ItemGroup></Project>",
@"<Project><ItemGroup><Reference><HintPath>path\to\file.dll</HintPath></Reference></ItemGroup></Project>"
)]
[InlineData( // multiple changes made
"<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>"
"<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 @@ -48,8 +48,10 @@ public class SupportedFrameworksFacts
Win10,
WinRt
];

// The following frameworks were included in NuGet.Client code but they were not official framework releases.
private readonly HashSet<NuGetFramework> UnofficialFrameworks = [
private readonly HashSet<NuGetFramework> UnofficialFrameworks =
[
NetStandard17,
NetStandardApp15,
];
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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public abstract class UpdateWorkerTestBase
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);
=> TestUpdateForProject(dependencyName, oldVersion, newVersion, (projectFilePath, projectContents), expectedProjectContents: projectContents, isTransitive, additionalFiles,
additionalFilesExpected: additionalFiles);

protected static Task TestUpdateForProject(
string dependencyName,
Expand Down

0 comments on commit e6836e1

Please sign in to comment.