From e6836e1e0a6315958395b145f4d60fb3f583cdbb Mon Sep 17 00:00:00 2001 From: Jan Trejbal Date: Mon, 29 Jan 2024 21:13:13 +0100 Subject: [PATCH] Apply Rider rules --- .../EntryPointTests.Update.cs | 220 ++++---- .../Commands/FrameworkCheckCommand.cs | 4 +- .../NuGetUpdater/NuGetUpdater.Cli/Program.cs | 6 +- .../Files/DotNetToolsJsonBuildFileTests.cs | 6 +- .../Files/GlobalJsonBuildFileTests.cs | 6 +- .../Files/ProjectBuildFileTests.cs | 23 +- .../SupportedFrameworkFacts.cs | 4 +- .../Update/UpdateWorker.DirsProj.cs | 132 ++--- .../Update/UpdateWorkerTestBase.cs | 3 +- .../Update/UpdateWorkerTests.DotNetTools.cs | 52 +- .../Update/UpdateWorkerTests.GlobalJson.cs | 14 +- .../UpdateWorkerTests.PackagesConfig.cs | 13 +- .../Update/UpdateWorkerTests.Sdk.cs | 532 +++++++++--------- .../Utilities/JsonHelperTests.cs | 25 +- .../Utilities/MSBuildHelperTests.cs | 303 ++++------ .../Utilities/SdkPackageUpdaterHelperTests.cs | 32 +- .../Utilities/SdkPackageUpdaterTests.cs | 124 ++-- .../Files/PackagesConfigBuildFile.cs | 1 + .../Files/ProjectBuildFile.cs | 9 +- .../FrameworkChecker/CompatabilityChecker.cs | 1 + .../FrameworkCompatibilityService.cs | 6 +- .../FrameworkChecker/SupportedFrameworks.cs | 94 +++- .../Updater/BindingRedirectManager.cs | 23 +- .../Updater/BindingRedirectResolver.cs | 1 - .../Updater/DotNetToolsJsonUpdater.cs | 5 +- .../Updater/GlobalJsonUpdater.cs | 3 +- .../Updater/PackagesConfigUpdater.cs | 3 +- .../Updater/SdkPackageUpdater.cs | 7 +- .../Updater/UpdaterWorker.cs | 9 +- .../NuGetUpdater.Core/Utilities/JsonHelper.cs | 24 +- .../Utilities/MSBuildHelper.cs | 11 +- .../NuGetUpdater.Core/Utilities/PathHelper.cs | 10 +- .../NuGetUpdater.sln.DotSettings.user | 25 + 33 files changed, 823 insertions(+), 908 deletions(-) create mode 100644 nuget/helpers/lib/NuGetUpdater/NuGetUpdater.sln.DotSettings.user diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs index 7475283f2a47..8f5d0850ef5f 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs @@ -32,77 +32,77 @@ public async Task WithSolution() ], [ ("path/to/solution.sln", """ - Microsoft Visual Studio Solution File, Format Version 12.00 - # Visual Studio 14 - VisualStudioVersion = 14.0.22705.0 - MinimumVisualStudioVersion = 10.0.40219.1 - Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "my", "my.csproj", "{782E0C0A-10D3-444D-9640-263D03D2B20C}" - EndProject - Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {782E0C0A-10D3-444D-9640-263D03D2B20C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {782E0C0A-10D3-444D-9640-263D03D2B20C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {782E0C0A-10D3-444D-9640-263D03D2B20C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {782E0C0A-10D3-444D-9640-263D03D2B20C}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - EndGlobal - """), + Microsoft Visual Studio Solution File, Format Version 12.00 + # Visual Studio 14 + VisualStudioVersion = 14.0.22705.0 + MinimumVisualStudioVersion = 10.0.40219.1 + Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "my", "my.csproj", "{782E0C0A-10D3-444D-9640-263D03D2B20C}" + EndProject + Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {782E0C0A-10D3-444D-9640-263D03D2B20C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {782E0C0A-10D3-444D-9640-263D03D2B20C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {782E0C0A-10D3-444D-9640-263D03D2B20C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {782E0C0A-10D3-444D-9640-263D03D2B20C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + EndGlobal + """), ("path/to/my.csproj", """ - - - - v4.5 - - - - - - - packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll - True - - - - - """), + + + + v4.5 + + + + + + + packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll + True + + + + + """), ("path/to/packages.config", """ - - - - """) + + + + """) ], [ ("path/to/my.csproj", """ - - - - v4.5 - - - - - - - packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll - True - - - - - """), + + + + v4.5 + + + + + + + packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + True + + + + + """), ("path/to/packages.config", """ - - - - - """) + + + + + """) ]); } @@ -126,54 +126,54 @@ public async Task WithProject() ], [ ("path/to/my.csproj", """ - - - - v4.5 - - - - - - - packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll - True - - - - - """), + + + + v4.5 + + + + + + + packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll + True + + + + + """), ("path/to/packages.config", """ - - - - """) + + + + """) ], [ ("path/to/my.csproj", """ - - - - v4.5 - - - - - - - packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll - True - - - - - """), + + + + v4.5 + + + + + + + packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + True + + + + + """), ("path/to/packages.config", """ - - - - - """) + + + + + """) ]); } @@ -233,7 +233,7 @@ public async Task WithDirsProjAndDirectoryBuildPropsThatIsOutOfDirectoryButStill """), ("other-dir/Directory.Build.props", """ - + @@ -280,7 +280,7 @@ public async Task WithDirsProjAndDirectoryBuildPropsThatIsOutOfDirectoryButStill """), ("other-dir/Directory.Build.props", """ - + diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/FrameworkCheckCommand.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/FrameworkCheckCommand.cs index f1927de12182..948e7d41efca 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/FrameworkCheckCommand.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/FrameworkCheckCommand.cs @@ -16,9 +16,7 @@ internal static Command GetCommand(Action 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; diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs index 6549831eba9b..830742ded050 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs @@ -13,11 +13,7 @@ internal static async Task Main(string[] args) var exitCode = 0; Action 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); diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/DotNetToolsJsonBuildFileTests.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/DotNetToolsJsonBuildFileTests.cs index 30d5339eb64f..f07d0990ef3d 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/DotNetToolsJsonBuildFileTests.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/DotNetToolsJsonBuildFileTests.cs @@ -38,11 +38,7 @@ public class DotnetToolsJsonBuildFileTests [Fact] public void GetDependencies_ReturnsDependencies() { - var expectedDependencies = new List - { - new("microsoft.botsay", "1.0.0", DependencyType.DotNetTool), - new("dotnetsay", "2.1.3", DependencyType.DotNetTool) - }; + var expectedDependencies = new List { new("microsoft.botsay", "1.0.0", DependencyType.DotNetTool), new("dotnetsay", "2.1.3", DependencyType.DotNetTool) }; var buildFile = GetBuildFile(); diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/GlobalJsonBuildFileTests.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/GlobalJsonBuildFileTests.cs index d71ef9d5336e..b259319641cb 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/GlobalJsonBuildFileTests.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/GlobalJsonBuildFileTests.cs @@ -53,11 +53,7 @@ public void GlobalJson_NotJson_DoesNotThrow() [Fact] public void GlobalJson_GetDependencies_ReturnsDependencies() { - var expectedDependencies = new List - { - new("My.Custom.Sdk", "5.0.0", DependencyType.MSBuildSdk), - new("My.Other.Sdk", "1.0.0-beta", DependencyType.MSBuildSdk) - }; + var expectedDependencies = new List { new("My.Custom.Sdk", "5.0.0", DependencyType.MSBuildSdk), new("My.Other.Sdk", "1.0.0-beta", DependencyType.MSBuildSdk) }; var buildFile = GetBuildFile(GlobalJson); diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/ProjectBuildFileTests.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/ProjectBuildFileTests.cs index 3e66e3cc2fd4..d1ef9f6b531f 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/ProjectBuildFileTests.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/ProjectBuildFileTests.cs @@ -74,10 +74,7 @@ public void ProjectCsProj_GetDependencies_ReturnsDependencies() [Fact] public void ProjectCsProj_ReferencedProjectPaths_ReturnsPaths() { - var expectedReferencedProjectPaths = new List - { - "/Library/Library.csproj" - }; + var expectedReferencedProjectPaths = new List { "/Library/Library.csproj" }; var buildFile = GetBuildFile(ProjectCsProj, "Project.csproj"); @@ -107,11 +104,7 @@ public void DirectoryPackagesProps_GetDependencies_ReturnsDependencies() [Fact] public void DirectoryPackagesProps_Properties_ReturnsProperties() { - var expectedProperties = new List> - { - new("ManagePackageVersionsCentrally", "true"), - new("CentralPackageTransitivePinningEnabled", "true") - }; + var expectedProperties = new List> { new("ManagePackageVersionsCentrally", "true"), new("CentralPackageTransitivePinningEnabled", "true") }; var buildFile = GetBuildFile(DirectoryPackagesProps, "Directory.Packages.props"); @@ -134,16 +127,16 @@ public void EmptyProject_GetDependencies_ReturnsNoDependencies() [Theory] [InlineData( // no change made - @"path\to\file.dll", - @"path\to\file.dll" + @"path\to\file.dll", + @"path\to\file.dll" )] [InlineData( // change from `/` to `\` - "path/to/file.dll", - @"path\to\file.dll" + "path/to/file.dll", + @"path\to\file.dll" )] [InlineData( // multiple changes made - "path1/to1/file1.dllpath2/to2/file2.dll", - @"path1\to1\file1.dllpath2\to2\file2.dll" + "path1/to1/file1.dllpath2/to2/file2.dll", + @"path1\to1\file1.dllpath2\to2\file2.dll" )] public void ReferenceHintPathsCanBeNormalized(string originalXml, string expectedXml) { diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/SupportedFrameworkFacts.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/SupportedFrameworkFacts.cs index 50336bba9150..38cfec321895 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/SupportedFrameworkFacts.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/SupportedFrameworkFacts.cs @@ -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 UnofficialFrameworks = [ + private readonly HashSet UnofficialFrameworks = + [ NetStandard17, NetStandardApp15, ]; diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorker.DirsProj.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorker.DirsProj.cs index b82abd17defa..028679a5271d 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorker.DirsProj.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorker.DirsProj.cs @@ -24,7 +24,7 @@ public async Task UpdateSingleDependencyInDirsProj() // initial projectContents: """ - + @@ -34,22 +34,22 @@ public async Task UpdateSingleDependencyInDirsProj() additionalFiles: [ ("src/test-project.csproj", - """ - - - netstandard2.0 - - - - - - - """) + """ + + + netstandard2.0 + + + + + + + """) ], // expected expectedProjectContents: """ - + @@ -59,17 +59,17 @@ public async Task UpdateSingleDependencyInDirsProj() additionalFilesExpected: [ ("src/test-project.csproj", - """ - - - netstandard2.0 - - - - - - - """) + """ + + + netstandard2.0 + + + + + + + """) ]); } @@ -101,7 +101,7 @@ public async Task UpdateSingleDependencyInNestedDirsProj() // initial projectContents: """ - + @@ -111,32 +111,32 @@ public async Task UpdateSingleDependencyInNestedDirsProj() additionalFiles: [ ("src/dirs.proj", - """ - - - - - - - - """), + """ + + + + + + + + """), ("src/test-project/test-project.csproj", - """ - - - netstandard2.0 - - - - - - - """) + """ + + + netstandard2.0 + + + + + + + """) ], // expected expectedProjectContents: """ - + @@ -146,27 +146,27 @@ public async Task UpdateSingleDependencyInNestedDirsProj() additionalFilesExpected: [ ("src/dirs.proj", - """ - - - - - - - - """), + """ + + + + + + + + """), ("src/test-project/test-project.csproj", - """ - - - netstandard2.0 - - - - - - - """) + """ + + + netstandard2.0 + + + + + + + """) ]); } diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs index 07f179ed159a..2ca0fd87601f 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs @@ -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, diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs index c92fc0bcb34a..f1880e12a2c9 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs @@ -23,7 +23,7 @@ public async Task NoChangeWhenDotNetToolsJsonNotFound() netstandard2.0 - + @@ -41,7 +41,7 @@ public async Task NoChangeWhenDependencyNotFound() netstandard2.0 - + @@ -77,7 +77,7 @@ public async Task NoChangeWhenDotNetToolsJsonInUnexpectedLocation() netstandard2.0 - + @@ -112,7 +112,7 @@ public async Task UpdateSingleDependencyInDirsProj() netstandard2.0 - + @@ -147,7 +147,7 @@ public async Task UpdateSingleDependencyInDirsProj() netstandard2.0 - + @@ -188,7 +188,7 @@ public async Task UpdateSingleDependencyWithComments() netstandard2.0 - + @@ -225,7 +225,7 @@ public async Task UpdateSingleDependencyWithComments() netstandard2.0 - + @@ -234,27 +234,27 @@ public async Task UpdateSingleDependencyWithComments() additionalFilesExpected: [ (".config/dotnet-tools.json", """ - { - // this is a comment - "version": 1, - "isRoot": true, - "tools": { - "microsoft.botsay": { - // this is a deep comment - "version": "1.1.0", - "commands": [ - "botsay" - ] - }, - "dotnetsay": { - "version": "2.1.3", - "commands": [ - "dotnetsay" - ] + { + // this is a comment + "version": 1, + "isRoot": true, + "tools": { + "microsoft.botsay": { + // this is a deep comment + "version": "1.1.0", + "commands": [ + "botsay" + ] + }, + "dotnetsay": { + "version": "2.1.3", + "commands": [ + "dotnetsay" + ] + } } } - } - """) + """) ]); } } diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs index 816d62497e1d..458a63d2fc2b 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs @@ -23,7 +23,7 @@ public async Task NoChangeWhenGlobalJsonNotFound() netstandard2.0 - + @@ -41,7 +41,7 @@ public async Task NoChangeWhenDependencyNotFound() netstandard2.0 - + @@ -71,7 +71,7 @@ public async Task NoChangeWhenGlobalJsonInUnexpectedLocation() netstandard2.0 - + > @@ -104,7 +104,7 @@ public async Task UpdateSingleDependency() netstandard2.0 - + @@ -130,7 +130,7 @@ public async Task UpdateSingleDependency() netstandard2.0 - + @@ -162,7 +162,7 @@ public async Task UpdateDependencyWithComments() netstandard2.0 - + @@ -190,7 +190,7 @@ public async Task UpdateDependencyWithComments() netstandard2.0 - + diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs index 2b4fe74e3f72..7d0116fe81fd 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs @@ -914,25 +914,20 @@ public async Task PackagesConfigUpdateCanHappenEvenWithMismatchedVersionNumbers( (string Path, string Content)[]? additionalFiles = null, (string Path, string Content)[]? additionalFilesExpected = null) { - var realizedAdditionalFiles = new List<(string Path, string Content)> - { - ("packages.config", packagesConfigContents), - }; + var realizedAdditionalFiles = new List<(string Path, string Content)> { ("packages.config", packagesConfigContents), }; if (additionalFiles is not null) { realizedAdditionalFiles.AddRange(additionalFiles); } - var realizedAdditionalFilesExpected = new List<(string Path, string Content)> - { - ("packages.config", expectedPackagesConfigContents), - }; + var realizedAdditionalFilesExpected = new List<(string Path, string Content)> { ("packages.config", expectedPackagesConfigContents), }; if (additionalFilesExpected is not null) { realizedAdditionalFilesExpected.AddRange(additionalFilesExpected); } - await TestUpdateForProject(dependencyName, oldVersion, newVersion, projectContents, expectedProjectContents, additionalFiles: realizedAdditionalFiles.ToArray(), additionalFilesExpected: realizedAdditionalFilesExpected.ToArray()); + await TestUpdateForProject(dependencyName, oldVersion, newVersion, projectContents, expectedProjectContents, additionalFiles: realizedAdditionalFiles.ToArray(), + additionalFilesExpected: realizedAdditionalFilesExpected.ToArray()); } } } diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs index fe640448aabc..4dea5d289c2a 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs @@ -30,7 +30,7 @@ public async Task UpdateVersionAttribute_InProjectFile_ForPackageReferenceInclud {tfm} - + @@ -42,7 +42,7 @@ public async Task UpdateVersionAttribute_InProjectFile_ForPackageReferenceInclud {tfm} - + @@ -81,7 +81,7 @@ public async Task UpdateFindsNearestNugetConfig_AndSucceeds() var privateNugetContent = """ - + @@ -90,16 +90,16 @@ public async Task UpdateFindsNearestNugetConfig_AndSucceeds() """; await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1", projectFile: (Path: "Directory/Project.csproj", Content: """ - - - netstandard2.0 - - - - - - """), - """ + + + netstandard2.0 + + + + + + """), + """ netstandard2.0 @@ -109,7 +109,7 @@ public async Task UpdateFindsNearestNugetConfig_AndSucceeds() """, - additionalFiles: + additionalFiles: [ (Path: "NuGet.config", Content: $""" @@ -121,7 +121,7 @@ public async Task UpdateFindsNearestNugetConfig_AndSucceeds() """), (Path: "Directory/NuGet.config", Content: privateNugetContent) - ]); + ]); } [Fact] @@ -140,7 +140,7 @@ public async Task UpdateReturnsEmptyArray_WhenBuildFails() """, - additionalFiles: + additionalFiles: [ (Path: "NuGet.config", Content: """ @@ -168,7 +168,7 @@ public async Task UpdateExactMatchVersionAttribute_InProjectFile_ForPackageRefer net6.0 - + @@ -180,7 +180,7 @@ public async Task UpdateExactMatchVersionAttribute_InProjectFile_ForPackageRefer net6.0 - + @@ -196,11 +196,11 @@ public async Task AddPackageReference_InProjectFile_ForTransientDependency() // initial projectContents: """ - + netcoreapp3.1 - + @@ -210,11 +210,11 @@ public async Task AddPackageReference_InProjectFile_ForTransientDependency() // expected expectedProjectContents: """ - + netcoreapp3.1 - + @@ -235,7 +235,7 @@ public async Task UpdateVersionAttribute_InProjectFile_ForAnalyzerPackageReferen netstandard2.0 - + all @@ -250,7 +250,7 @@ public async Task UpdateVersionAttribute_InProjectFile_ForAnalyzerPackageReferen netstandard2.0 - + all @@ -272,7 +272,7 @@ public async Task UpdateVersionAttribute_InProjectFile_ForMultiplePackageReferen netstandard2.0 - + @@ -285,7 +285,7 @@ public async Task UpdateVersionAttribute_InProjectFile_ForMultiplePackageReferen netstandard2.0 - + @@ -305,7 +305,7 @@ public async Task UpdateVersionAttribute_InProjectFile_ForPackageReferenceUpdate netstandard2.0 - + @@ -318,7 +318,7 @@ public async Task UpdateVersionAttribute_InProjectFile_ForPackageReferenceUpdate netstandard2.0 - + @@ -338,7 +338,7 @@ public async Task UpdateVersionAttribute_InDirectoryPackages_ForPackageVersion() netstandard2.0 - + @@ -351,7 +351,7 @@ public async Task UpdateVersionAttribute_InDirectoryPackages_ForPackageVersion() true - + @@ -364,7 +364,7 @@ public async Task UpdateVersionAttribute_InDirectoryPackages_ForPackageVersion() netstandard2.0 - + @@ -377,7 +377,7 @@ public async Task UpdateVersionAttribute_InDirectoryPackages_ForPackageVersion() true - + @@ -397,7 +397,7 @@ public async Task UpdateExactMatchVersionAttribute_InDirectoryPackages_ForPackag netstandard2.0 - + @@ -410,7 +410,7 @@ public async Task UpdateExactMatchVersionAttribute_InDirectoryPackages_ForPackag true - + @@ -423,7 +423,7 @@ public async Task UpdateExactMatchVersionAttribute_InDirectoryPackages_ForPackag netstandard2.0 - + @@ -436,7 +436,7 @@ public async Task UpdateExactMatchVersionAttribute_InDirectoryPackages_ForPackag true - + @@ -456,7 +456,7 @@ public async Task UpdatePropertyValue_InProjectFile_ForPackageReferenceIncludeWi netstandard2.0 9.0.1 - + @@ -469,7 +469,7 @@ public async Task UpdatePropertyValue_InProjectFile_ForPackageReferenceIncludeWi netstandard2.0 13.0.1 - + @@ -488,7 +488,7 @@ public async Task UpdateDifferentCasedPropertyValue_InProjectFile_ForPackageRefe netstandard2.0 9.0.1 - + @@ -501,7 +501,7 @@ public async Task UpdateDifferentCasedPropertyValue_InProjectFile_ForPackageRefe netstandard2.0 13.0.1 - + @@ -520,7 +520,7 @@ public async Task UpdatePropertyValue_InProjectFile_ForPackageReferenceInclude() netstandard2.0 9.0.1 - + @@ -533,7 +533,7 @@ public async Task UpdatePropertyValue_InProjectFile_ForPackageReferenceInclude() netstandard2.0 13.0.1 - + @@ -552,7 +552,7 @@ public async Task UpdateExactMatchPropertyValue_InProjectFile_ForPackageReferenc netstandard2.0 [9.0.1] - + @@ -565,7 +565,7 @@ public async Task UpdateExactMatchPropertyValue_InProjectFile_ForPackageReferenc netstandard2.0 [13.0.1] - + @@ -584,7 +584,7 @@ public async Task UpdateVersionAttributeAndPropertyValue_InProjectFile_ForMultip netstandard2.0 9.0.1 - + @@ -598,7 +598,7 @@ public async Task UpdateVersionAttributeAndPropertyValue_InProjectFile_ForMultip netstandard2.0 13.0.1 - + @@ -618,7 +618,7 @@ public async Task UpdatePropertyValue_InProjectFile_ForPackageReferenceUpdate() netstandard2.0 9.0.1 - + @@ -632,7 +632,7 @@ public async Task UpdatePropertyValue_InProjectFile_ForPackageReferenceUpdate() netstandard2.0 13.0.1 - + @@ -652,7 +652,7 @@ public async Task UpdatePropertyValue_InDirectoryProps_ForPackageVersion() netstandard2.0 - + @@ -666,7 +666,7 @@ public async Task UpdatePropertyValue_InDirectoryProps_ForPackageVersion() true 9.0.1 - + @@ -679,7 +679,7 @@ public async Task UpdatePropertyValue_InDirectoryProps_ForPackageVersion() netstandard2.0 - + @@ -693,7 +693,7 @@ public async Task UpdatePropertyValue_InDirectoryProps_ForPackageVersion() true 13.0.1 - + @@ -713,7 +713,7 @@ public async Task UpdateExactMatchPropertyValue_InDirectoryProps_ForPackageVersi netstandard2.0 - + @@ -727,7 +727,7 @@ public async Task UpdateExactMatchPropertyValue_InDirectoryProps_ForPackageVersi true [9.0.1] - + @@ -740,7 +740,7 @@ public async Task UpdateExactMatchPropertyValue_InDirectoryProps_ForPackageVersi netstandard2.0 - + @@ -754,7 +754,7 @@ public async Task UpdateExactMatchPropertyValue_InDirectoryProps_ForPackageVersi true [13.0.1] - + @@ -774,7 +774,7 @@ public async Task UpdateVersionOverrideAttributeAndPropertyValue_InProjectFileAn netstandard2.0 - + @@ -788,7 +788,7 @@ public async Task UpdateVersionOverrideAttributeAndPropertyValue_InProjectFileAn true 9.0.1 - + @@ -801,7 +801,7 @@ public async Task UpdateVersionOverrideAttributeAndPropertyValue_InProjectFileAn netstandard2.0 - + @@ -815,7 +815,7 @@ public async Task UpdateVersionOverrideAttributeAndPropertyValue_InProjectFileAn true 13.0.1 - + @@ -844,7 +844,7 @@ public async Task UpdateVersionAttribute_InDirectoryProps_ForGlobalPackageRefere true - + @@ -866,7 +866,7 @@ public async Task UpdateVersionAttribute_InDirectoryProps_ForGlobalPackageRefere true - + @@ -896,7 +896,7 @@ public async Task UpdatePropertyValue_InDirectoryProps_ForGlobalPackageReference true 9.0.1 - + @@ -919,7 +919,7 @@ public async Task UpdatePropertyValue_InDirectoryProps_ForGlobalPackageReference true 13.0.1 - + @@ -938,7 +938,7 @@ public async Task UpdatePropertyValue_InDirectoryProps_ForPackageReferenceInclud netstandard2.0 - + @@ -961,7 +961,7 @@ public async Task UpdatePropertyValue_InDirectoryProps_ForPackageReferenceInclud netstandard2.0 - + @@ -988,11 +988,11 @@ public async Task UpdatePropertyValue_InProps_ForPackageReferenceInclude() projectContents: """ - + netstandard2.0 - + @@ -1013,11 +1013,11 @@ public async Task UpdatePropertyValue_InProps_ForPackageReferenceInclude() expectedProjectContents: """ - + netstandard2.0 - + @@ -1047,7 +1047,7 @@ public async Task UpdatePropertyValue_InProps_ForPackageVersion() netstandard2.0 - + @@ -1062,7 +1062,7 @@ public async Task UpdatePropertyValue_InProps_ForPackageVersion() true - + @@ -1082,7 +1082,7 @@ public async Task UpdatePropertyValue_InProps_ForPackageVersion() netstandard2.0 - + @@ -1097,7 +1097,7 @@ public async Task UpdatePropertyValue_InProps_ForPackageVersion() true - + @@ -1124,7 +1124,7 @@ public async Task UpdatePropertyValue_InProps_ThenSubstituted_ForPackageVersion( netstandard2.0 - + @@ -1140,7 +1140,7 @@ public async Task UpdatePropertyValue_InProps_ThenSubstituted_ForPackageVersion( true $(NewtonsoftJsonVersion) - + @@ -1160,7 +1160,7 @@ public async Task UpdatePropertyValue_InProps_ThenSubstituted_ForPackageVersion( netstandard2.0 - + @@ -1176,7 +1176,7 @@ public async Task UpdatePropertyValue_InProps_ThenSubstituted_ForPackageVersion( true $(NewtonsoftJsonVersion) - + @@ -1203,7 +1203,7 @@ public async Task UpdatePropertyValues_InProps_ThenRedefinedAndSubstituted_ForPa netstandard2.0 - + @@ -1219,7 +1219,7 @@ public async Task UpdatePropertyValues_InProps_ThenRedefinedAndSubstituted_ForPa true $(NewtonsoftJsonVersion) - + @@ -1240,7 +1240,7 @@ public async Task UpdatePropertyValues_InProps_ThenRedefinedAndSubstituted_ForPa netstandard2.0 - + @@ -1256,7 +1256,7 @@ public async Task UpdatePropertyValues_InProps_ThenRedefinedAndSubstituted_ForPa true $(NewtonsoftJsonVersion) - + @@ -1565,13 +1565,13 @@ public async Task AvoidPackageDowngradeWhenUpdatingDependency() await TestUpdateForProject("Microsoft.VisualStudio.Sdk.TestFramework.Xunit", "17.2.7", "17.6.16", projectContents: """ - + $(PreferredTargetFramework) false - + @@ -1613,13 +1613,13 @@ public async Task AvoidPackageDowngradeWhenUpdatingDependency() ], expectedProjectContents: """ - + $(PreferredTargetFramework) false - + @@ -1668,11 +1668,11 @@ public async Task AddTransitiveDependencyByAddingPackageReferenceAndVersion() // initial projectContents: """ - + net5.0 - + @@ -1696,11 +1696,11 @@ public async Task AddTransitiveDependencyByAddingPackageReferenceAndVersion() // expected expectedProjectContents: """ - + net5.0 - + @@ -1732,12 +1732,12 @@ public async Task PinTransitiveDependencyByAddingPackageVersion() // initial projectContents: """ - + $(NoWarn);NETSDK1138 net5.0 - + @@ -1762,12 +1762,12 @@ public async Task PinTransitiveDependencyByAddingPackageVersion() // expected expectedProjectContents: """ - + $(NoWarn);NETSDK1138 net5.0 - + @@ -1797,15 +1797,15 @@ public async Task PropsFileNameWithDifferentCasing() { await TestUpdateForProject("Newtonsoft.Json", "12.0.1", "13.0.1", projectContents: """ - - - net7.0 - - - - - - """, + + + net7.0 + + + + + + """, additionalFiles: [ ("Directory.Build.props", """ @@ -1824,15 +1824,15 @@ public async Task PropsFileNameWithDifferentCasing() ], // no change expectedProjectContents: """ - - - net7.0 - - - - - - """, + + + net7.0 + + + + + + """, additionalFilesExpected: [ // no change @@ -1859,25 +1859,25 @@ public async Task VersionAttributeWithDifferentCasing_VersionNumberInline() // the version attribute in the project has an all lowercase name await TestUpdateForProject("Newtonsoft.Json", "12.0.1", "13.0.1", projectContents: """ - - - net7.0 - - - - - - """, + + + net7.0 + + + + + + """, expectedProjectContents: """ - - - net7.0 - - - - - - """ + + + net7.0 + + + + + + """ ); } @@ -1887,15 +1887,15 @@ public async Task VersionAttributeWithDifferentCasing_VersionNumberInProperty() // the version attribute in the project has an all lowercase name await TestUpdateForProject("Newtonsoft.Json", "12.0.1", "13.0.1", projectContents: """ - - - net7.0 - - - - - - """, + + + net7.0 + + + + + + """, additionalFiles: [ ("Directory.Build.props", """ @@ -1913,15 +1913,15 @@ public async Task VersionAttributeWithDifferentCasing_VersionNumberInProperty() ], // no change expectedProjectContents: """ - - - net7.0 - - - - - - """, + + + net7.0 + + + + + + """, additionalFilesExpected: [ // no change @@ -1948,15 +1948,15 @@ public async Task DirectoryPackagesPropsDoesCentralPackagePinningGetsUpdatedIfTr await TestUpdateForProject("xunit.assert", "2.5.2", "2.5.3", isTransitive: true, projectContents: """ - - - net7.0 - - - - - - """, + + + net7.0 + + + + + + """, additionalFiles: [ ("Directory.Packages.props", """ @@ -1973,15 +1973,15 @@ public async Task DirectoryPackagesPropsDoesCentralPackagePinningGetsUpdatedIfTr """) ], expectedProjectContents: """ - - - net7.0 - - - - - - """, + + + net7.0 + + + + + + """, additionalFilesExpected: [ ("Directory.Packages.props", """ @@ -2006,15 +2006,15 @@ public async Task DirectoryPackagesPropsDoesNotGetDuplicateEntryIfCentralTransit await TestUpdateForProject("xunit.assert", "2.5.2", "2.5.3", isTransitive: true, projectContents: """ - - - net7.0 - - - - - - """, + + + net7.0 + + + + + + """, additionalFiles: [ ("Directory.Packages.props", """ @@ -2031,15 +2031,15 @@ public async Task DirectoryPackagesPropsDoesNotGetDuplicateEntryIfCentralTransit """) ], expectedProjectContents: """ - - - net7.0 - - - - - - """, + + + net7.0 + + + + + + """, additionalFilesExpected: [ ("Directory.Packages.props", """ @@ -2063,25 +2063,25 @@ public async Task PackageWithFourPartVersionCanBeUpdated() { await TestUpdateForProject("AWSSDK.Core", "3.7.204.13", "3.7.204.14", projectContents: """ - - - net7.0 - - - - - - """, + + + net7.0 + + + + + + """, expectedProjectContents: """ - - - net7.0 - - - - - - """ + + + net7.0 + + + + + + """ ); } @@ -2090,25 +2090,25 @@ public async Task PackageWithOnlyBuildTargetsCanBeUpdated() { await TestUpdateForProject("Microsoft.Windows.Compatibility", "7.0.0", "8.0.0", projectContents: """ - - - net5.0 - - - - - - """, + + + net5.0 + + + + + + """, expectedProjectContents: """ - - - net5.0 - - - - - - """ + + + net5.0 + + + + + + """ ); } @@ -2117,31 +2117,31 @@ public async Task UpdatePackageVersionFromPropertiesWithAndWithoutConditions() { await TestUpdateForProject("Newtonsoft.Json", "12.0.1", "13.0.1", projectContents: """ - - - netstandard2.0 - 7.0.1 - 12.0.1 - 9.0.1 - - - - - - """, + + + netstandard2.0 + 7.0.1 + 12.0.1 + 9.0.1 + + + + + + """, expectedProjectContents: """ - - - netstandard2.0 - 7.0.1 - 13.0.1 - 9.0.1 - - - - - - """ + + + netstandard2.0 + 7.0.1 + 13.0.1 + 9.0.1 + + + + + + """ ); } @@ -2150,29 +2150,29 @@ public async Task UpdatePackageVersionFromPropertyWithConditionCheckingForEmptyS { await TestUpdateForProject("Newtonsoft.Json", "12.0.1", "13.0.1", projectContents: """ - - - netstandard2.0 - 12.0.1 - 9.0.1 - - - - - - """, + + + netstandard2.0 + 12.0.1 + 9.0.1 + + + + + + """, expectedProjectContents: """ - - - netstandard2.0 - 13.0.1 - 9.0.1 - - - - - - """ + + + netstandard2.0 + 13.0.1 + 9.0.1 + + + + + + """ ); } } diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/JsonHelperTests.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/JsonHelperTests.cs index 87737f4982b9..38b22b4b9a36 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/JsonHelperTests.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/JsonHelperTests.cs @@ -46,12 +46,7 @@ yield return } """, // property path - new[] - { - "tools", - "microsoft.botsay", - "version" - }, + new[] { "tools", "microsoft.botsay", "version" }, // new value "1.1.0", // expected json @@ -98,11 +93,7 @@ yield return } """, // property path - new[] - { - "msbuild-sdks", - "Microsoft.Build.NoTargets" - }, + new[] { "msbuild-sdks", "Microsoft.Build.NoTargets" }, // new value "3.7.0", // expected json @@ -149,12 +140,7 @@ yield return } """, // property path - new[] - { - "tools", - "Microsoft.BotSay", - "version" - }, + new[] { "tools", "Microsoft.BotSay", "version" }, // new value "1.1.0", // expected json @@ -195,10 +181,7 @@ yield return } """, // property path - new[] - { - "path2" - }, + new[] { "path2" }, // new value "new-value", // expected json diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs index e9f8eaed14cf..92a711f61629 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs @@ -30,10 +30,7 @@ public void GetRootedValue_FindsValue() """; - var propertyInfo = new Dictionary - { - { "PackageVersion1", "1.1.1" }, - }; + var propertyInfo = new Dictionary { { "PackageVersion1", "1.1.1" }, }; // Act var rootValue = MSBuildHelper.GetRootedValue(projectContents, propertyInfo); @@ -65,11 +62,7 @@ public async Task GetRootedValue_DoesNotRecurseAsync() """; - var propertyInfo = new Dictionary - { - { "PackageVersion1", "$(PackageVersion2)" }, - { "PackageVersion2", "$(PackageVersion1)" } - }; + var propertyInfo = new Dictionary { { "PackageVersion1", "$(PackageVersion2)" }, { "PackageVersion2", "$(PackageVersion1)" } }; // This is needed to make the timeout work. Without that we could get caugth in an infinite loop. await Task.Delay(1); @@ -150,24 +143,17 @@ public async Task AllPackageDependenciesCanBeTraversed() using var temp = new TemporaryDirectory(); var expectedDependencies = new Dependency[] { - new("Microsoft.Bcl.AsyncInterfaces", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.DependencyInjection", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.DependencyInjection.Abstractions", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.Logging", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.Logging.Abstractions", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.Options", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.Primitives", "7.0.0", DependencyType.Unknown), - new("System.Buffers", "4.5.1", DependencyType.Unknown), - new("System.ComponentModel.Annotations", "5.0.0", DependencyType.Unknown), - new("System.Diagnostics.DiagnosticSource", "7.0.0", DependencyType.Unknown), - new("System.Memory", "4.5.5", DependencyType.Unknown), - new("System.Numerics.Vectors", "4.4.0", DependencyType.Unknown), - new("System.Runtime.CompilerServices.Unsafe", "6.0.0", DependencyType.Unknown), - new("System.Threading.Tasks.Extensions", "4.5.4", DependencyType.Unknown), - new("NETStandard.Library", "2.0.3", DependencyType.Unknown), + new("Microsoft.Bcl.AsyncInterfaces", "7.0.0", DependencyType.Unknown), new("Microsoft.Extensions.DependencyInjection", "7.0.0", DependencyType.Unknown), + new("Microsoft.Extensions.DependencyInjection.Abstractions", "7.0.0", DependencyType.Unknown), new("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown), + new("Microsoft.Extensions.Logging", "7.0.0", DependencyType.Unknown), new("Microsoft.Extensions.Logging.Abstractions", "7.0.0", DependencyType.Unknown), + new("Microsoft.Extensions.Options", "7.0.0", DependencyType.Unknown), new("Microsoft.Extensions.Primitives", "7.0.0", DependencyType.Unknown), + new("System.Buffers", "4.5.1", DependencyType.Unknown), new("System.ComponentModel.Annotations", "5.0.0", DependencyType.Unknown), + new("System.Diagnostics.DiagnosticSource", "7.0.0", DependencyType.Unknown), new("System.Memory", "4.5.5", DependencyType.Unknown), + new("System.Numerics.Vectors", "4.4.0", DependencyType.Unknown), new("System.Runtime.CompilerServices.Unsafe", "6.0.0", DependencyType.Unknown), + new("System.Threading.Tasks.Extensions", "4.5.4", DependencyType.Unknown), new("NETStandard.Library", "2.0.3", DependencyType.Unknown), }; - var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "netstandard2.0", new[] { new Dependency("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown) }); + var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "netstandard2.0", + new[] { new Dependency("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown) }); Assert.Equal(expectedDependencies, actualDependencies); } @@ -177,87 +163,52 @@ public async Task AllPackageDependencies_DoNotTruncateLongDependencyLists() using var temp = new TemporaryDirectory(); var expectedDependencies = new Dependency[] { - new("Castle.Core", "4.4.1", DependencyType.Unknown), - new("Microsoft.ApplicationInsights", "2.10.0", DependencyType.Unknown), + new("Castle.Core", "4.4.1", DependencyType.Unknown), new("Microsoft.ApplicationInsights", "2.10.0", DependencyType.Unknown), new("Microsoft.ApplicationInsights.Agent.Intercept", "2.4.0", DependencyType.Unknown), new("Microsoft.ApplicationInsights.DependencyCollector", "2.10.0", DependencyType.Unknown), new("Microsoft.ApplicationInsights.PerfCounterCollector", "2.10.0", DependencyType.Unknown), new("Microsoft.ApplicationInsights.WindowsServer", "2.10.0", DependencyType.Unknown), new("Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel", "2.10.0", DependencyType.Unknown), - new("Microsoft.AspNet.TelemetryCorrelation", "1.0.5", DependencyType.Unknown), - new("Microsoft.Bcl.AsyncInterfaces", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.Caching.Abstractions", "1.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.Caching.Memory", "1.0.0", DependencyType.Unknown), + new("Microsoft.AspNet.TelemetryCorrelation", "1.0.5", DependencyType.Unknown), new("Microsoft.Bcl.AsyncInterfaces", "7.0.0", DependencyType.Unknown), + new("Microsoft.Extensions.Caching.Abstractions", "1.0.0", DependencyType.Unknown), new("Microsoft.Extensions.Caching.Memory", "1.0.0", DependencyType.Unknown), new("Microsoft.Extensions.DependencyInjection", "7.0.0", DependencyType.Unknown), new("Microsoft.Extensions.DependencyInjection.Abstractions", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.DiagnosticAdapter", "1.1.0", DependencyType.Unknown), - new("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.Logging", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.Logging.Abstractions", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.Options", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.PlatformAbstractions", "1.1.0", DependencyType.Unknown), - new("Microsoft.Extensions.Primitives", "7.0.0", DependencyType.Unknown), - new("Moq", "4.16.1", DependencyType.Unknown), - new("MSTest.TestFramework", "2.1.0", DependencyType.Unknown), - new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown), - new("System", "4.1.311.2", DependencyType.Unknown), - new("System.Buffers", "4.5.1", DependencyType.Unknown), - new("System.Collections.Concurrent", "4.3.0", DependencyType.Unknown), - new("System.Collections.Immutable", "1.3.0", DependencyType.Unknown), - new("System.Collections.NonGeneric", "4.3.0", DependencyType.Unknown), - new("System.Collections.Specialized", "4.3.0", DependencyType.Unknown), - new("System.ComponentModel", "4.3.0", DependencyType.Unknown), - new("System.ComponentModel.Annotations", "5.0.0", DependencyType.Unknown), - new("System.ComponentModel.Primitives", "4.3.0", DependencyType.Unknown), - new("System.ComponentModel.TypeConverter", "4.3.0", DependencyType.Unknown), - new("System.Core", "3.5.21022.801", DependencyType.Unknown), - new("System.Data.Common", "4.3.0", DependencyType.Unknown), - new("System.Diagnostics.DiagnosticSource", "7.0.0", DependencyType.Unknown), - new("System.Diagnostics.PerformanceCounter", "4.5.0", DependencyType.Unknown), - new("System.Diagnostics.StackTrace", "4.3.0", DependencyType.Unknown), - new("System.Dynamic.Runtime", "4.3.0", DependencyType.Unknown), - new("System.IO.FileSystem.Primitives", "4.3.0", DependencyType.Unknown), - new("System.Linq", "4.3.0", DependencyType.Unknown), - new("System.Linq.Expressions", "4.3.0", DependencyType.Unknown), - new("System.Memory", "4.5.5", DependencyType.Unknown), - new("System.Net.WebHeaderCollection", "4.3.0", DependencyType.Unknown), - new("System.Numerics.Vectors", "4.4.0", DependencyType.Unknown), - new("System.ObjectModel", "4.3.0", DependencyType.Unknown), - new("System.Private.DataContractSerialization", "4.3.0", DependencyType.Unknown), - new("System.Reflection.Emit", "4.3.0", DependencyType.Unknown), - new("System.Reflection.Emit.ILGeneration", "4.3.0", DependencyType.Unknown), - new("System.Reflection.Emit.Lightweight", "4.3.0", DependencyType.Unknown), - new("System.Reflection.Metadata", "1.4.1", DependencyType.Unknown), - new("System.Reflection.TypeExtensions", "4.3.0", DependencyType.Unknown), - new("System.Runtime.CompilerServices.Unsafe", "6.0.0", DependencyType.Unknown), - new("System.Runtime.InteropServices.RuntimeInformation", "4.3.0", DependencyType.Unknown), - new("System.Runtime.Numerics", "4.3.0", DependencyType.Unknown), - new("System.Runtime.Serialization.Json", "4.3.0", DependencyType.Unknown), - new("System.Runtime.Serialization.Primitives", "4.3.0", DependencyType.Unknown), - new("System.Security.Claims", "4.3.0", DependencyType.Unknown), - new("System.Security.Cryptography.OpenSsl", "4.3.0", DependencyType.Unknown), - new("System.Security.Cryptography.Primitives", "4.3.0", DependencyType.Unknown), - new("System.Security.Principal", "4.3.0", DependencyType.Unknown), - new("System.Text.RegularExpressions", "4.3.0", DependencyType.Unknown), - new("System.Threading", "4.3.0", DependencyType.Unknown), - new("System.Threading.Tasks.Extensions", "4.5.4", DependencyType.Unknown), - new("System.Threading.Thread", "4.3.0", DependencyType.Unknown), - new("System.Threading.ThreadPool", "4.3.0", DependencyType.Unknown), - new("System.Xml.ReaderWriter", "4.3.0", DependencyType.Unknown), - new("System.Xml.XDocument", "4.3.0", DependencyType.Unknown), - new("System.Xml.XmlDocument", "4.3.0", DependencyType.Unknown), - new("System.Xml.XmlSerializer", "4.3.0", DependencyType.Unknown), - new("Microsoft.ApplicationInsights.Web", "2.10.0", DependencyType.Unknown), - new("MSTest.TestAdapter", "2.1.0", DependencyType.Unknown), - new("NETStandard.Library", "2.0.3", DependencyType.Unknown), + new("Microsoft.Extensions.DiagnosticAdapter", "1.1.0", DependencyType.Unknown), new("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown), + new("Microsoft.Extensions.Logging", "7.0.0", DependencyType.Unknown), new("Microsoft.Extensions.Logging.Abstractions", "7.0.0", DependencyType.Unknown), + new("Microsoft.Extensions.Options", "7.0.0", DependencyType.Unknown), new("Microsoft.Extensions.PlatformAbstractions", "1.1.0", DependencyType.Unknown), + new("Microsoft.Extensions.Primitives", "7.0.0", DependencyType.Unknown), new("Moq", "4.16.1", DependencyType.Unknown), + new("MSTest.TestFramework", "2.1.0", DependencyType.Unknown), new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown), + new("System", "4.1.311.2", DependencyType.Unknown), new("System.Buffers", "4.5.1", DependencyType.Unknown), + new("System.Collections.Concurrent", "4.3.0", DependencyType.Unknown), new("System.Collections.Immutable", "1.3.0", DependencyType.Unknown), + new("System.Collections.NonGeneric", "4.3.0", DependencyType.Unknown), new("System.Collections.Specialized", "4.3.0", DependencyType.Unknown), + new("System.ComponentModel", "4.3.0", DependencyType.Unknown), new("System.ComponentModel.Annotations", "5.0.0", DependencyType.Unknown), + new("System.ComponentModel.Primitives", "4.3.0", DependencyType.Unknown), new("System.ComponentModel.TypeConverter", "4.3.0", DependencyType.Unknown), + new("System.Core", "3.5.21022.801", DependencyType.Unknown), new("System.Data.Common", "4.3.0", DependencyType.Unknown), + new("System.Diagnostics.DiagnosticSource", "7.0.0", DependencyType.Unknown), new("System.Diagnostics.PerformanceCounter", "4.5.0", DependencyType.Unknown), + new("System.Diagnostics.StackTrace", "4.3.0", DependencyType.Unknown), new("System.Dynamic.Runtime", "4.3.0", DependencyType.Unknown), + new("System.IO.FileSystem.Primitives", "4.3.0", DependencyType.Unknown), new("System.Linq", "4.3.0", DependencyType.Unknown), + new("System.Linq.Expressions", "4.3.0", DependencyType.Unknown), new("System.Memory", "4.5.5", DependencyType.Unknown), + new("System.Net.WebHeaderCollection", "4.3.0", DependencyType.Unknown), new("System.Numerics.Vectors", "4.4.0", DependencyType.Unknown), + new("System.ObjectModel", "4.3.0", DependencyType.Unknown), new("System.Private.DataContractSerialization", "4.3.0", DependencyType.Unknown), + new("System.Reflection.Emit", "4.3.0", DependencyType.Unknown), new("System.Reflection.Emit.ILGeneration", "4.3.0", DependencyType.Unknown), + new("System.Reflection.Emit.Lightweight", "4.3.0", DependencyType.Unknown), new("System.Reflection.Metadata", "1.4.1", DependencyType.Unknown), + new("System.Reflection.TypeExtensions", "4.3.0", DependencyType.Unknown), new("System.Runtime.CompilerServices.Unsafe", "6.0.0", DependencyType.Unknown), + new("System.Runtime.InteropServices.RuntimeInformation", "4.3.0", DependencyType.Unknown), new("System.Runtime.Numerics", "4.3.0", DependencyType.Unknown), + new("System.Runtime.Serialization.Json", "4.3.0", DependencyType.Unknown), new("System.Runtime.Serialization.Primitives", "4.3.0", DependencyType.Unknown), + new("System.Security.Claims", "4.3.0", DependencyType.Unknown), new("System.Security.Cryptography.OpenSsl", "4.3.0", DependencyType.Unknown), + new("System.Security.Cryptography.Primitives", "4.3.0", DependencyType.Unknown), new("System.Security.Principal", "4.3.0", DependencyType.Unknown), + new("System.Text.RegularExpressions", "4.3.0", DependencyType.Unknown), new("System.Threading", "4.3.0", DependencyType.Unknown), + new("System.Threading.Tasks.Extensions", "4.5.4", DependencyType.Unknown), new("System.Threading.Thread", "4.3.0", DependencyType.Unknown), + new("System.Threading.ThreadPool", "4.3.0", DependencyType.Unknown), new("System.Xml.ReaderWriter", "4.3.0", DependencyType.Unknown), + new("System.Xml.XDocument", "4.3.0", DependencyType.Unknown), new("System.Xml.XmlDocument", "4.3.0", DependencyType.Unknown), + new("System.Xml.XmlSerializer", "4.3.0", DependencyType.Unknown), new("Microsoft.ApplicationInsights.Web", "2.10.0", DependencyType.Unknown), + new("MSTest.TestAdapter", "2.1.0", DependencyType.Unknown), new("NETStandard.Library", "2.0.3", DependencyType.Unknown), }; - var packages = new[] { - new Dependency("System", "4.1.311.2", DependencyType.Unknown), - new Dependency("System.Core", "3.5.21022.801", DependencyType.Unknown), - new Dependency("Moq", "4.16.1", DependencyType.Unknown), - new Dependency("Castle.Core", "4.4.1", DependencyType.Unknown), - new Dependency("MSTest.TestAdapter", "2.1.0", DependencyType.Unknown), - new Dependency("MSTest.TestFramework", "2.1.0", DependencyType.Unknown), + var packages = new[] + { + new Dependency("System", "4.1.311.2", DependencyType.Unknown), new Dependency("System.Core", "3.5.21022.801", DependencyType.Unknown), + new Dependency("Moq", "4.16.1", DependencyType.Unknown), new Dependency("Castle.Core", "4.4.1", DependencyType.Unknown), + new Dependency("MSTest.TestAdapter", "2.1.0", DependencyType.Unknown), new Dependency("MSTest.TestFramework", "2.1.0", DependencyType.Unknown), new Dependency("Microsoft.ApplicationInsights", "2.10.0", DependencyType.Unknown), new Dependency("Microsoft.ApplicationInsights.Agent.Intercept", "2.4.0", DependencyType.Unknown), new Dependency("Microsoft.ApplicationInsights.DependencyCollector", "2.10.0", DependencyType.Unknown), @@ -265,8 +216,7 @@ public async Task AllPackageDependencies_DoNotTruncateLongDependencyLists() new Dependency("Microsoft.ApplicationInsights.Web", "2.10.0", DependencyType.Unknown), new Dependency("Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel", "2.10.0", DependencyType.Unknown), new Dependency("Microsoft.ApplicationInsights.WindowsServer", "2.10.0", DependencyType.Unknown), - new Dependency("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown), - new Dependency("Newtonsoft.Json", "12.0.1", DependencyType.Unknown) + new Dependency("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown), new Dependency("Newtonsoft.Json", "12.0.1", DependencyType.Unknown) }; var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "netstandard2.0", packages); for (int i = 0; i < actualDependencies.Length; i++) @@ -275,6 +225,7 @@ public async Task AllPackageDependencies_DoNotTruncateLongDependencyLists() var ed = expectedDependencies[i]; Assert.Equal(ed, ad); } + Assert.Equal(expectedDependencies, actualDependencies); } @@ -284,26 +235,18 @@ public async Task AllPackageDependencies_DoNotIncludeUpdateOnlyPackages() using var temp = new TemporaryDirectory(); var expectedDependencies = new Dependency[] { - new("Microsoft.Bcl.AsyncInterfaces", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.DependencyInjection", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.DependencyInjection.Abstractions", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.Logging", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.Logging.Abstractions", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.Options", "7.0.0", DependencyType.Unknown), - new("Microsoft.Extensions.Primitives", "7.0.0", DependencyType.Unknown), - new("System.Buffers", "4.5.1", DependencyType.Unknown), - new("System.ComponentModel.Annotations", "5.0.0", DependencyType.Unknown), - new("System.Diagnostics.DiagnosticSource", "7.0.0", DependencyType.Unknown), - new("System.Memory", "4.5.5", DependencyType.Unknown), - new("System.Numerics.Vectors", "4.4.0", DependencyType.Unknown), - new("System.Runtime.CompilerServices.Unsafe", "6.0.0", DependencyType.Unknown), - new("System.Threading.Tasks.Extensions", "4.5.4", DependencyType.Unknown), - new("NETStandard.Library", "2.0.3", DependencyType.Unknown), + new("Microsoft.Bcl.AsyncInterfaces", "7.0.0", DependencyType.Unknown), new("Microsoft.Extensions.DependencyInjection", "7.0.0", DependencyType.Unknown), + new("Microsoft.Extensions.DependencyInjection.Abstractions", "7.0.0", DependencyType.Unknown), new("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown), + new("Microsoft.Extensions.Logging", "7.0.0", DependencyType.Unknown), new("Microsoft.Extensions.Logging.Abstractions", "7.0.0", DependencyType.Unknown), + new("Microsoft.Extensions.Options", "7.0.0", DependencyType.Unknown), new("Microsoft.Extensions.Primitives", "7.0.0", DependencyType.Unknown), + new("System.Buffers", "4.5.1", DependencyType.Unknown), new("System.ComponentModel.Annotations", "5.0.0", DependencyType.Unknown), + new("System.Diagnostics.DiagnosticSource", "7.0.0", DependencyType.Unknown), new("System.Memory", "4.5.5", DependencyType.Unknown), + new("System.Numerics.Vectors", "4.4.0", DependencyType.Unknown), new("System.Runtime.CompilerServices.Unsafe", "6.0.0", DependencyType.Unknown), + new("System.Threading.Tasks.Extensions", "4.5.4", DependencyType.Unknown), new("NETStandard.Library", "2.0.3", DependencyType.Unknown), }; - var packages = new[] { - new Dependency("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown), - new Dependency("Newtonsoft.Json", "12.0.1", DependencyType.Unknown, IsUpdate: true) + var packages = new[] + { + new Dependency("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown), new Dependency("Newtonsoft.Json", "12.0.1", DependencyType.Unknown, IsUpdate: true) }; var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "netstandard2.0", packages); Assert.Equal(expectedDependencies, actualDependencies); @@ -326,36 +269,33 @@ public async Task AllPackageDependenciesCanBeFoundWithNuGetConfig() Environment.SetEnvironmentVariable("NUGET_HTTP_CACHE_PATH", tempNuGetHttpCacheDirectory); // First validate that we are unable to find dependencies for the package version without a NuGet.config. - var dependenciesNoNuGetConfig = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "netstandard2.0", new[] { new Dependency("Microsoft.CodeAnalysis.Common", "4.8.0-3.23457.5", DependencyType.Unknown) }); + var dependenciesNoNuGetConfig = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "netstandard2.0", + new[] { new Dependency("Microsoft.CodeAnalysis.Common", "4.8.0-3.23457.5", DependencyType.Unknown) }); Assert.Equal(Array.Empty(), dependenciesNoNuGetConfig); // Write the NuGet.config and try again. await File.WriteAllTextAsync(Path.Combine(temp.DirectoryPath, "NuGet.Config"), """ - - - - - - - - - """); + + + + + + + + + """); var expectedDependencies = new Dependency[] { - new("Microsoft.CodeAnalysis.Common", "4.8.0-3.23457.5", DependencyType.Unknown), - new("System.Buffers", "4.5.1", DependencyType.Unknown), - new("System.Collections.Immutable", "7.0.0", DependencyType.Unknown), - new("System.Memory", "4.5.5", DependencyType.Unknown), - new("System.Numerics.Vectors", "4.4.0", DependencyType.Unknown), - new("System.Reflection.Metadata", "7.0.0", DependencyType.Unknown), - new("System.Runtime.CompilerServices.Unsafe", "6.0.0", DependencyType.Unknown), - new("System.Text.Encoding.CodePages", "7.0.0", DependencyType.Unknown), - new("System.Threading.Tasks.Extensions", "4.5.4", DependencyType.Unknown), - new("Microsoft.CodeAnalysis.Analyzers", "3.3.4", DependencyType.Unknown), + new("Microsoft.CodeAnalysis.Common", "4.8.0-3.23457.5", DependencyType.Unknown), new("System.Buffers", "4.5.1", DependencyType.Unknown), + new("System.Collections.Immutable", "7.0.0", DependencyType.Unknown), new("System.Memory", "4.5.5", DependencyType.Unknown), + new("System.Numerics.Vectors", "4.4.0", DependencyType.Unknown), new("System.Reflection.Metadata", "7.0.0", DependencyType.Unknown), + new("System.Runtime.CompilerServices.Unsafe", "6.0.0", DependencyType.Unknown), new("System.Text.Encoding.CodePages", "7.0.0", DependencyType.Unknown), + new("System.Threading.Tasks.Extensions", "4.5.4", DependencyType.Unknown), new("Microsoft.CodeAnalysis.Analyzers", "3.3.4", DependencyType.Unknown), new("NETStandard.Library", "2.0.3", DependencyType.Unknown), }; - var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "netstandard2.0", new[] { new Dependency("Microsoft.CodeAnalysis.Common", "4.8.0-3.23457.5", DependencyType.Unknown) }); + var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "netstandard2.0", + new[] { new Dependency("Microsoft.CodeAnalysis.Common", "4.8.0-3.23457.5", DependencyType.Unknown) }); Assert.Equal(expectedDependencies, actualDependencies); } finally @@ -383,10 +323,7 @@ yield return """) }, // expected dependencies - new Dependency[] - { - new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown) - } + new Dependency[] { new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown) } ]; // version is a child-node of the package reference @@ -406,10 +343,7 @@ yield return """) }, // expected dependencies - new Dependency[] - { - new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown) - } + new Dependency[] { new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown) } ]; // version is in property in same file @@ -430,10 +364,7 @@ yield return """) }, // expected dependencies - new Dependency[] - { - new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown) - } + new Dependency[] { new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown) } ]; // version is a property not triggered by a condition @@ -456,10 +387,7 @@ yield return """) }, // expected dependencies - new Dependency[] - { - new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown) - } + new Dependency[] { new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown) } ]; // version is a property not triggered by a quoted condition @@ -482,10 +410,7 @@ yield return """) }, // expected dependencies - new Dependency[] - { - new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown) - } + new Dependency[] { new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown) } }; // version is a property with a condition checking for an empty string @@ -508,10 +433,7 @@ yield return """) }, // expected dependencies - new Dependency[] - { - new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown) - } + new Dependency[] { new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown) } ]; // version is a property with a quoted condition checking for an empty string @@ -534,10 +456,7 @@ yield return """) }, // expected dependencies - new Dependency[] - { - new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown) - } + new Dependency[] { new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown) } }; // version is set in one file, used in another @@ -547,13 +466,13 @@ yield return new[] { ("Packages.props", """ - - - - - - - """), + + + + + + + """), ("project.csproj", """ @@ -566,11 +485,7 @@ yield return """) }, // expected dependencies - new Dependency[] - { - new("Azure.Identity", "1.6.0", DependencyType.Unknown), - new("Microsoft.Data.SqlClient", "5.1.4", DependencyType.Unknown, IsUpdate: true) - } + new Dependency[] { new("Azure.Identity", "1.6.0", DependencyType.Unknown), new("Microsoft.Data.SqlClient", "5.1.4", DependencyType.Unknown, IsUpdate: true) } ]; // version is set in one file, used in another @@ -590,20 +505,16 @@ yield return """), ("Packages.props", """ - - - - - - - """) + + + + + + + """) }, // expected dependencies - new Dependency[] - { - new("Azure.Identity", "1.6.0", DependencyType.Unknown), - new("Microsoft.Data.SqlClient", "5.1.4", DependencyType.Unknown, IsUpdate: true) - } + new Dependency[] { new("Azure.Identity", "1.6.0", DependencyType.Unknown), new("Microsoft.Data.SqlClient", "5.1.4", DependencyType.Unknown, IsUpdate: true) } ]; } @@ -640,11 +551,7 @@ yield return EndGlobalSection EndGlobal """, - new[] - { - "src/Some.Project/SomeProject.csproj", - "src/Some.Project.Test/Some.Project.Test.csproj", - } + new[] { "src/Some.Project/SomeProject.csproj", "src/Some.Project.Test/Some.Project.Test.csproj", } ]; } } diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterHelperTests.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterHelperTests.cs index bef7bd6abca2..a2e957fdd15e 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterHelperTests.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterHelperTests.cs @@ -36,13 +36,7 @@ public async Task DirectoryBuildFilesAreOnlyPulledInFromParentDirectories() """) ); var actualBuildFilePaths = await LoadBuildFilesFromTemp(temporaryDirectory, "src/SomeProject.csproj"); - var expectedBuildFilePaths = new[] - { - "src/SomeProject.csproj", - "Directory.Build.props", - "props/Versions.props", - "src/Directory.Build.targets", - }; + var expectedBuildFilePaths = new[] { "src/SomeProject.csproj", "Directory.Build.props", "props/Versions.props", "src/Directory.Build.targets", }; Assert.Equal(expectedBuildFilePaths, actualBuildFilePaths); } @@ -70,11 +64,7 @@ public async Task BuildFileEnumerationWorksEvenWithNonSupportedSdkInGlobalJson(s """) ); var actualBuildFilePaths = await LoadBuildFilesFromTemp(temporaryDirectory, $"{projectSubpath}/SomeProject.csproj"); - var expectedBuildFilePaths = new[] - { - $"{projectSubpath}SomeProject.csproj", - $"{projectSubpath}Directory.Build.props", - }; + var expectedBuildFilePaths = new[] { $"{projectSubpath}SomeProject.csproj", $"{projectSubpath}Directory.Build.props", }; Assert.Equal(expectedBuildFilePaths, actualBuildFilePaths); Assert.True(File.Exists($"{temporaryDirectory.DirectoryPath}/{globalJsonSubpath}global.json"), "global.json was not restored"); } @@ -109,12 +99,7 @@ public async Task BuildFileEnumerationWithNonStandardMSBuildSdkAndNonSupportedSd """) ); var actualBuildFilePaths = await LoadBuildFilesFromTemp(temporaryDirectory, "SomeProject.csproj"); - var expectedBuildFilePaths = new[] - { - "SomeProject.csproj", - "NoTargets.props", - "Versions.props", - }; + var expectedBuildFilePaths = new[] { "SomeProject.csproj", "NoTargets.props", "Versions.props", }; Assert.Equal(expectedBuildFilePaths, actualBuildFilePaths); var globalJsonContent = await File.ReadAllTextAsync($"{temporaryDirectory.DirectoryPath}/global.json"); Assert.Contains("99.99.99", globalJsonContent); // ensure global.json was restored @@ -135,11 +120,7 @@ public async Task BuildFileEnumerationWithUnsuccessfulImport() """) ); var actualBuildFilePaths = await LoadBuildFilesFromTemp(temporaryDirectory, "NonBuildingProject.csproj"); - var expectedBuildFilePaths = new[] - { - "NonBuildingProject.csproj", - "Directory.Build.props", - }; + var expectedBuildFilePaths = new[] { "NonBuildingProject.csproj", "Directory.Build.props", }; Assert.Equal(expectedBuildFilePaths, actualBuildFilePaths); } @@ -162,10 +143,7 @@ public async Task BuildFileEnumerationWithGlobalJsonWithComments() """) ); var actualBuildFilePaths = await LoadBuildFilesFromTemp(temporaryDirectory, "NonBuildingProject.csproj"); - var expectedBuildFilePaths = new[] - { - "NonBuildingProject.csproj", - }; + var expectedBuildFilePaths = new[] { "NonBuildingProject.csproj", }; Assert.Equal(expectedBuildFilePaths, actualBuildFilePaths); } diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterTests.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterTests.cs index c1182e3591e5..c0f2048995b7 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterTests.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterTests.cs @@ -31,7 +31,7 @@ public static IEnumerable GetDependencyUpdates() // Simple case yield return new object[] { - new [] + new[] { (Path: "src/Project.csproj", Content: """ @@ -44,7 +44,7 @@ public static IEnumerable GetDependencyUpdates() """) }, // starting contents - new [] + new[] { (Path: "src/Project.csproj", Content: """ @@ -66,32 +66,32 @@ yield return new[] { (Path: "src/Project/Project.csproj", Content: """ - - - netstandard2.0 - - - - - - - """), + + + netstandard2.0 + + + + + + + """), }, // starting contents new[] { // If a dependency has a version constraint outside of our new-version, we don't update anything (Path: "src/Project/Project.csproj", Content: """ - - - netstandard2.0 - - - - - - - """), - },// expected contents + + + netstandard2.0 + + + + + + + """), + }, // expected contents "AWSSDK.Core", "3.3.21.19", "3.7.300.20", @@ -104,51 +104,51 @@ yield return new[] { (Path: "src/Project2/Project2.csproj", Content: """ - - - netstandard2.0 - - - - - - - """), + + + netstandard2.0 + + + + + + + """), (Path: "src/Project/Project.csproj", Content: """ - - - netstandard2.0 - - - - - - """), + + + netstandard2.0 + + + + + + """), }, // starting contents new[] { (Path: "src/Project2/Project2.csproj", Content: """ - - - netstandard2.0 - - - - - - - """), // starting contents + + + netstandard2.0 + + + + + + + """), // starting contents (Path: "src/Project/Project.csproj", Content: """ - - - netstandard2.0 - - - - - - """), - },// expected contents + + + netstandard2.0 + + + + + + """), + }, // expected contents "Newtonsoft.Json", "12.0.1", "13.0.1", diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/PackagesConfigBuildFile.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/PackagesConfigBuildFile.cs index c9c37940987d..2f4b892141b1 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/PackagesConfigBuildFile.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/PackagesConfigBuildFile.cs @@ -11,6 +11,7 @@ internal sealed class PackagesConfigBuildFile : XmlBuildFile { public static PackagesConfigBuildFile Open(string repoRootPath, string path) => Parse(repoRootPath, path, File.ReadAllText(path)); + public static PackagesConfigBuildFile Parse(string repoRootPath, string path, string xml) => new(repoRootPath, path, Parser.ParseText(xml)); diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/ProjectBuildFile.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/ProjectBuildFile.cs index e20602da4692..cb4e79df0d08 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/ProjectBuildFile.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/ProjectBuildFile.cs @@ -11,6 +11,7 @@ internal sealed class ProjectBuildFile : XmlBuildFile { public static ProjectBuildFile Open(string repoRootPath, string path) => Parse(repoRootPath, path, File.ReadAllText(path)); + public static ProjectBuildFile Parse(string repoRootPath, string path, string xml) => new(repoRootPath, path, Parser.ParseText(xml)); @@ -31,9 +32,9 @@ public ProjectBuildFile(string repoRootPath, string path, XmlDocumentSyntax cont .SelectMany(e => e.Elements); public IEnumerable PackageItemNodes => ItemNodes.Where(e => - e.Name.Equals("PackageReference", StringComparison.OrdinalIgnoreCase) || - e.Name.Equals("GlobalPackageReference", StringComparison.OrdinalIgnoreCase) || - e.Name.Equals("PackageVersion", StringComparison.OrdinalIgnoreCase)); + e.Name.Equals("PackageReference", StringComparison.OrdinalIgnoreCase) || + e.Name.Equals("GlobalPackageReference", StringComparison.OrdinalIgnoreCase) || + e.Name.Equals("PackageVersion", StringComparison.OrdinalIgnoreCase)); public IEnumerable GetDependencies() => PackageItemNodes .Select(GetDependency) @@ -42,7 +43,7 @@ public ProjectBuildFile(string repoRootPath, string path, XmlDocumentSyntax cont private static Dependency? GetDependency(IXmlElementSyntax element) { var name = element.GetAttributeOrSubElementValue("Include", StringComparison.OrdinalIgnoreCase) - ?? element.GetAttributeOrSubElementValue("Update", StringComparison.OrdinalIgnoreCase); + ?? element.GetAttributeOrSubElementValue("Update", StringComparison.OrdinalIgnoreCase); if (name is null || name.StartsWith("@(")) { return null; diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs index 3dc1b8b4d457..e49f4c9faf3c 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs @@ -33,6 +33,7 @@ static NuGetFramework ParseFramework(string tfm) // effort by including just the platform. framework = new NuGetFramework(framework.Framework, framework.Version, framework.Platform, FrameworkConstants.EmptyVersion); } + return framework; } } diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/FrameworkCompatibilityService.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/FrameworkCompatibilityService.cs index e3e6642e1590..6e82a4f8e17d 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/FrameworkCompatibilityService.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/FrameworkCompatibilityService.cs @@ -66,11 +66,7 @@ public ISet GetCompatibleFrameworks(IEnumerable? matrix.Add( SupportedFrameworks.Net60Windows7, - new HashSet - { - SupportedFrameworks.Net60Windows, SupportedFrameworks.Net60Windows7, - SupportedFrameworks.Net70Windows, SupportedFrameworks.Net70Windows7 - } + new HashSet { SupportedFrameworks.Net60Windows, SupportedFrameworks.Net60Windows7, SupportedFrameworks.Net70Windows, SupportedFrameworks.Net70Windows7 } ); return matrix; diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/SupportedFrameworks.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/SupportedFrameworks.cs index 91540f302d33..8f74122ccf86 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/SupportedFrameworks.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/SupportedFrameworks.cs @@ -69,22 +69,88 @@ static SupportedFrameworks() { AllSupportedNuGetFrameworks = new List { - MonoAndroid, MonoMac, MonoTouch, + MonoAndroid, + MonoMac, + MonoTouch, Native, - Net11, Net2, Net35, Net4, Net403, Net45, Net451, Net452, Net46, Net461, Net462, Net463, Net47, Net471, Net472, Net48, Net481, - Net50, Net50Windows, - Net60, Net60Android, Net60Ios, Net60MacCatalyst, Net60MacOs, Net60TvOs, Net60Windows, - Net70, Net70Android, Net70Ios, Net70MacCatalyst, Net70MacOs, Net70TvOs, Net70Windows, - Net80, Net80Android, Net80Ios, Net80MacCatalyst, Net80MacOs, Net80TvOs, Net80Windows, - NetCore, NetCore45, NetCore451, - NetCoreApp10, NetCoreApp11, NetCoreApp20, NetCoreApp21, NetCoreApp22, NetCoreApp30, NetCoreApp31, + Net11, + Net2, + Net35, + Net4, + Net403, + Net45, + Net451, + Net452, + Net46, + Net461, + Net462, + Net463, + Net47, + Net471, + Net472, + Net48, + Net481, + Net50, + Net50Windows, + Net60, + Net60Android, + Net60Ios, + Net60MacCatalyst, + Net60MacOs, + Net60TvOs, + Net60Windows, + Net70, + Net70Android, + Net70Ios, + Net70MacCatalyst, + Net70MacOs, + Net70TvOs, + Net70Windows, + Net80, + Net80Android, + Net80Ios, + Net80MacCatalyst, + Net80MacOs, + Net80TvOs, + Net80Windows, + NetCore, + NetCore45, + NetCore451, + NetCoreApp10, + NetCoreApp11, + NetCoreApp20, + NetCoreApp21, + NetCoreApp22, + NetCoreApp30, + NetCoreApp31, NetMf, - NetStandard, NetStandard10, NetStandard11, NetStandard12, NetStandard13, NetStandard14, NetStandard15, NetStandard16, NetStandard20, NetStandard21, - SL4, SL5, - Tizen3, Tizen4, Tizen6, - UAP, UAP10, - WP, WP7, WP75, WP8, WP81, WPA81, - XamarinIOs, XamarinMac, XamarinTvOs, XamarinWatchOs + NetStandard, + NetStandard10, + NetStandard11, + NetStandard12, + NetStandard13, + NetStandard14, + NetStandard15, + NetStandard16, + NetStandard20, + NetStandard21, + SL4, + SL5, + Tizen3, + Tizen4, + Tizen6, + UAP, + UAP10, + WP, + WP7, + WP75, + WP8, + WP81, + WPA81, + XamarinIOs, + XamarinMac, + XamarinTvOs, + XamarinWatchOs }; } diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs index 742d7c864d57..cffc61522edb 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs @@ -1,5 +1,4 @@ extern alias CoreV2; - using System; using System.Collections.Generic; using System.IO; @@ -152,7 +151,7 @@ static bool IsConfigFile(IXmlElementSyntax element) var path = Path.GetFileName(content); return (element.Name == "None" && string.Equals(path, "app.config", StringComparison.OrdinalIgnoreCase)) - || (element.Name == "Content" && string.Equals(path, "web.config", StringComparison.OrdinalIgnoreCase)); + || (element.Name == "Content" && string.Equals(path, "web.config", StringComparison.OrdinalIgnoreCase)); } static string GetConfigFileName(XmlDocumentSyntax document) @@ -173,13 +172,13 @@ static string GenerateDefaultAppConfig(XmlDocumentSyntax document) { var frameworkVersion = GetFrameworkVersion(document); return $""" - - - - - - - """; + + + + + + + """; } static string? GetFrameworkVersion(XmlDocumentSyntax document) @@ -290,11 +289,7 @@ static Dictionary<(string Name, string PublicKeyToken), XElement> GetAssemblyBin // We're going to need to know which element is associated with what binding for removal var assemblyElementPairs = from dependentAssemblyElement in dependencyAssemblyElements - select new - { - Binding = AssemblyBinding.Parse(dependentAssemblyElement), - Element = dependentAssemblyElement - }; + select new { Binding = AssemblyBinding.Parse(dependentAssemblyElement), Element = dependentAssemblyElement }; // Return a mapping from binding to element return assemblyElementPairs.ToDictionary(p => (p.Binding.Name, p.Binding.PublicKeyToken), p => p.Element); diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectResolver.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectResolver.cs index a2e5b0e40a6c..964e48c2157e 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectResolver.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectResolver.cs @@ -1,5 +1,4 @@ extern alias CoreV2; - using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs index bfaa85013525..93cd0dd49fa2 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs @@ -8,7 +8,8 @@ namespace NuGetUpdater.Core; internal static class DotNetToolsJsonUpdater { - public static async Task UpdateDependencyAsync(string repoRootPath, string workspacePath, string dependencyName, string previousDependencyVersion, string newDependencyVersion, Logger logger) + public static async Task UpdateDependencyAsync(string repoRootPath, string workspacePath, string dependencyName, string previousDependencyVersion, string newDependencyVersion, + Logger logger) { var buildFiles = LoadBuildFiles(repoRootPath, workspacePath, logger); if (buildFiles.Length == 0) @@ -21,7 +22,7 @@ public static async Task UpdateDependencyAsync(string repoRootPath, string works var filesToUpdate = buildFiles.Where(f => - f.GetDependencies().Any(d => d.Name.Equals(dependencyName, StringComparison.OrdinalIgnoreCase))) + f.GetDependencies().Any(d => d.Name.Equals(dependencyName, StringComparison.OrdinalIgnoreCase))) .ToImmutableArray(); if (filesToUpdate.Length == 0) { diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs index fe76deedcac4..34ab17324ada 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs @@ -7,7 +7,8 @@ namespace NuGetUpdater.Core; internal static class GlobalJsonUpdater { - public static async Task UpdateDependencyAsync(string repoRootPath, string globalJsonPath, string dependencyName, string previousDependencyVersion, string newDependencyVersion, Logger logger) + public static async Task UpdateDependencyAsync(string repoRootPath, string globalJsonPath, string dependencyName, string previousDependencyVersion, string newDependencyVersion, + Logger logger) { if (!File.Exists(globalJsonPath)) { diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs index f16c9425461d..f4800a21d36d 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs @@ -15,7 +15,8 @@ namespace NuGetUpdater.Core; internal static class PackagesConfigUpdater { - public static async Task UpdateDependencyAsync(string repoRootPath, string projectPath, string dependencyName, string previousDependencyVersion, string newDependencyVersion, bool isTransitive, Logger logger) + public static async Task UpdateDependencyAsync(string repoRootPath, string projectPath, string dependencyName, string previousDependencyVersion, string newDependencyVersion, + bool isTransitive, Logger logger) { logger.Log($" Found {NuGetHelper.PackagesConfigFileName}; running with NuGet.exe"); diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SdkPackageUpdater.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SdkPackageUpdater.cs index b52091263e4c..80bbc347e6ac 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SdkPackageUpdater.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SdkPackageUpdater.cs @@ -13,7 +13,8 @@ namespace NuGetUpdater.Core; internal static class SdkPackageUpdater { - public static async Task UpdateDependencyAsync(string repoRootPath, string projectPath, string dependencyName, string previousDependencyVersion, string newDependencyVersion, bool isTransitive, Logger logger) + public static async Task UpdateDependencyAsync(string repoRootPath, string projectPath, string dependencyName, string previousDependencyVersion, string newDependencyVersion, + bool isTransitive, Logger logger) { // SDK-style project, modify the XML directly logger.Log(" Running for SDK-style project"); @@ -281,9 +282,9 @@ private static async Task AddTransitiveDependencyAsync(string projectPath, strin foreach (var packageNode in packageNodes) { var versionAttribute = packageNode.GetAttribute("Version", StringComparison.OrdinalIgnoreCase) - ?? packageNode.GetAttribute("VersionOverride", StringComparison.OrdinalIgnoreCase); + ?? packageNode.GetAttribute("VersionOverride", StringComparison.OrdinalIgnoreCase); var versionElement = packageNode.Elements.FirstOrDefault(e => e.Name.Equals("Version", StringComparison.OrdinalIgnoreCase)) - ?? packageNode.Elements.FirstOrDefault(e => e.Name.Equals("VersionOverride", StringComparison.OrdinalIgnoreCase)); + ?? packageNode.Elements.FirstOrDefault(e => e.Name.Equals("VersionOverride", StringComparison.OrdinalIgnoreCase)); if (versionAttribute is not null) { // Is this the case where version is specified with property substitution? diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs index 615bcb3e8aad..6a912ead9cc6 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs @@ -51,7 +51,8 @@ public async Task RunAsync(string repoRootPath, string workspacePath, string dep _processedGlobalJsonPaths.Clear(); } - private async Task RunForSolutionAsync(string repoRootPath, string solutionPath, string dependencyName, string previousDependencyVersion, string newDependencyVersion, bool isTransitive) + private async Task RunForSolutionAsync(string repoRootPath, string solutionPath, string dependencyName, string previousDependencyVersion, string newDependencyVersion, + bool isTransitive) { _logger.Log($"Running for solution [{Path.GetRelativePath(repoRootPath, solutionPath)}]"); var projectPaths = MSBuildHelper.GetProjectPathsFromSolution(solutionPath); @@ -61,7 +62,8 @@ private async Task RunForSolutionAsync(string repoRootPath, string solutionPath, } } - private async Task RunForProjFileAsync(string repoRootPath, string projFilePath, string dependencyName, string previousDependencyVersion, string newDependencyVersion, bool isTransitive) + private async Task RunForProjFileAsync(string repoRootPath, string projFilePath, string dependencyName, string previousDependencyVersion, string newDependencyVersion, + bool isTransitive) { _logger.Log($"Running for proj file [{Path.GetRelativePath(repoRootPath, projFilePath)}]"); if (!File.Exists(projFilePath)) @@ -81,7 +83,8 @@ private async Task RunForProjFileAsync(string repoRootPath, string projFilePath, } } - private async Task RunForProjectAsync(string repoRootPath, string projectPath, string dependencyName, string previousDependencyVersion, string newDependencyVersion, bool isTransitive) + private async Task RunForProjectAsync(string repoRootPath, string projectPath, string dependencyName, string previousDependencyVersion, string newDependencyVersion, + bool isTransitive) { _logger.Log($"Running for project [{projectPath}]"); diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/JsonHelper.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/JsonHelper.cs index 8c587b25bfac..140e526dc4c8 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/JsonHelper.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/JsonHelper.cs @@ -12,10 +12,7 @@ namespace NuGetUpdater.Core.Utilities { internal static class JsonHelper { - public static JsonDocumentOptions DocumentOptions { get; } = new JsonDocumentOptions - { - CommentHandling = JsonCommentHandling.Skip, - }; + public static JsonDocumentOptions DocumentOptions { get; } = new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip, }; public static JsonNode? ParseNode(string content) { @@ -25,18 +22,11 @@ internal static class JsonHelper public static string UpdateJsonProperty(string json, string[] propertyPath, string newValue, StringComparison comparisonType = StringComparison.Ordinal) { - var readerOptions = new JsonReaderOptions - { - CommentHandling = JsonCommentHandling.Allow, - }; + var readerOptions = new JsonReaderOptions { CommentHandling = JsonCommentHandling.Allow, }; var bytes = Encoding.UTF8.GetBytes(json); var reader = new Utf8JsonReader(bytes, readerOptions); using var ms = new MemoryStream(); - var writerOptions = new JsonWriterOptions - { - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, - Indented = true, - }; + var writerOptions = new JsonWriterOptions { Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, Indented = true, }; var writer = new Utf8JsonWriter(ms, writerOptions); var pathDepth = -1; @@ -71,6 +61,7 @@ public static string UpdateJsonProperty(string json, string[] propertyPath, stri // let the default block comment writer handle it writer.WriteCommentValue(reader.GetComment()); } + break; case JsonTokenType.EndArray: writer.WriteEndArray(); @@ -200,6 +191,7 @@ private static string GetCurrentTokenTriviaPrefix(int tokenStartIndex, string or { prefixStart--; } + goto done; default: // found regular character; move forward one and quit @@ -208,7 +200,7 @@ private static string GetCurrentTokenTriviaPrefix(int tokenStartIndex, string or } } - done: + done: var prefix = originalJson.Substring(prefixStart, tokenStartIndex - prefixStart); return prefix; } @@ -216,8 +208,8 @@ private static string GetCurrentTokenTriviaPrefix(int tokenStartIndex, string or private static bool IsPreceedingCharacterEqual(string originalText, int currentIndex, char expectedCharacter) { return currentIndex > 0 - && currentIndex < originalText.Length - && originalText[currentIndex - 1] == expectedCharacter; + && currentIndex < originalText.Length + && originalText[currentIndex - 1] == expectedCharacter; } } } diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs index 20c0ff0b7aa4..82fe0b43aa08 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs @@ -416,10 +416,7 @@ internal static async Task> LoadBuildFiles(stri var sdks = json?["msbuild-sdks"]; if (sdks is not null) { - var newObject = new Dictionary() - { - ["msbuild-sdks"] = sdks, - }; + var newObject = new Dictionary() { ["msbuild-sdks"] = sdks, }; var newContent = JsonSerializer.Serialize(newObject); await File.WriteAllTextAsync(globalJsonPath, newContent); } @@ -430,11 +427,7 @@ internal static async Task> LoadBuildFiles(stri // load the project even if it imports a file that doesn't exist (e.g. a file that's generated at restore // or build time). using var projectCollection = new ProjectCollection(); // do this in a one-off instance and don't pollute the global collection - var project = Project.FromFile(projectPath, new ProjectOptions - { - LoadSettings = ProjectLoadSettings.IgnoreMissingImports, - ProjectCollection = projectCollection, - }); + var project = Project.FromFile(projectPath, new ProjectOptions { LoadSettings = ProjectLoadSettings.IgnoreMissingImports, ProjectCollection = projectCollection, }); buildFileList.AddRange(project.Imports.Select(i => i.ImportedProject.FullPath.NormalizePathToUnix())); } catch (InvalidProjectFileException) diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs index 6056a45aa106..94e61f66aec9 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs @@ -6,14 +6,8 @@ namespace NuGetUpdater.Core; internal static class PathHelper { - private static readonly EnumerationOptions _caseInsensitiveEnumerationOptions = new() - { - MatchCasing = MatchCasing.CaseInsensitive, - }; - private static readonly EnumerationOptions _caseSensitiveEnumerationOptions = new() - { - MatchCasing = MatchCasing.CaseSensitive, - }; + private static readonly EnumerationOptions _caseInsensitiveEnumerationOptions = new() { MatchCasing = MatchCasing.CaseInsensitive, }; + private static readonly EnumerationOptions _caseSensitiveEnumerationOptions = new() { MatchCasing = MatchCasing.CaseSensitive, }; public static string JoinPath(string? path1, string path2) { diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.sln.DotSettings.user b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.sln.DotSettings.user new file mode 100644 index 000000000000..38a144b632cc --- /dev/null +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.sln.DotSettings.user @@ -0,0 +1,25 @@ + + + + + True + <SessionState ContinuousTestingMode="0" IsActive="True" Name="FrameworkCheck" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <TestAncestor> + <TestId>xUnit::BDBEBF91-F5FD-4589-B4FB-B3DE3103B04B::net8.0::NuGetUpdater.Cli.Test.EntryPointTests+FrameworkCheck</TestId> + <TestId>xUnit::BDBEBF91-F5FD-4589-B4FB-B3DE3103B04B::net8.0::NuGetUpdater.Cli.Test.EntryPointTests+Update</TestId> + <TestId>xUnit::AE3E29CD-0F66-4A66-93C1-440D701BD4F7::net8.0::NuGetUpdater.Core.Test.Files.DotnetToolsJsonBuildFileTests</TestId> + <TestId>xUnit::AE3E29CD-0F66-4A66-93C1-440D701BD4F7::net8.0::NuGetUpdater.Core.Test.Files.GlobalJsonBuildFileTests</TestId> + <TestId>xUnit::AE3E29CD-0F66-4A66-93C1-440D701BD4F7::net8.0::NuGetUpdater.Core.Test.Files.PackagesConfigBuildFileTests</TestId> + <TestId>xUnit::AE3E29CD-0F66-4A66-93C1-440D701BD4F7::net8.0::NuGetUpdater.Core.Test.Files.ProjectBuildFileTests</TestId> + <TestId>xUnit::AE3E29CD-0F66-4A66-93C1-440D701BD4F7::net8.0::NuGetUpdater.Core.Test.FrameworkChecker.CompatibilityCheckerFacts</TestId> + <TestId>xUnit::AE3E29CD-0F66-4A66-93C1-440D701BD4F7::net8.0::NuGetUpdater.Core.Test.FrameworkChecker.FrameworkCompatibilityServiceFacts</TestId> + <TestId>xUnit::AE3E29CD-0F66-4A66-93C1-440D701BD4F7::net8.0::NuGetUpdater.Core.Test.FrameworkChecker.SupportedFrameworksFacts</TestId> + <TestId>xUnit::AE3E29CD-0F66-4A66-93C1-440D701BD4F7::net8.0::NuGetUpdater.Core.Test.Update.PackagesConfigUpdaterTests</TestId> + <TestId>xUnit::AE3E29CD-0F66-4A66-93C1-440D701BD4F7::net8.0::NuGetUpdater.Core.Test.Update.UpdateWorkerTests</TestId> + <TestId>xUnit::AE3E29CD-0F66-4A66-93C1-440D701BD4F7::net8.0::NuGetUpdater.Core.Test.Utilities.JsonHelperTests</TestId> + <TestId>xUnit::AE3E29CD-0F66-4A66-93C1-440D701BD4F7::net8.0::NuGetUpdater.Core.Test.Utilities.MSBuildHelperTests</TestId> + <TestId>xUnit::AE3E29CD-0F66-4A66-93C1-440D701BD4F7::net8.0::NuGetUpdater.Core.Test.Utilities.SdkPackageUpdaterHelperTests</TestId> + <TestId>xUnit::AE3E29CD-0F66-4A66-93C1-440D701BD4F7::net8.0::NuGetUpdater.Core.Test.Utilities.SdkPackageUpdaterTests</TestId> + </TestAncestor> +</SessionState> + \ No newline at end of file