From ed98b38882d1ef29fa4e0b1770700de52f34e770 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 17 Jul 2023 13:27:35 -0700 Subject: [PATCH 01/12] Make methods static that don't use instance data --- global.json | 2 +- .../WebCmdlet/Common/WebRequestPSCmdlet.Common.cs | 6 +++--- .../host/msh/PendingProgress.cs | 12 +++--------- .../engine/Modules/RemoveModuleCommand.cs | 2 +- .../engine/Modules/ScriptAnalysis.cs | 2 +- src/System.Management.Automation/engine/TypeTable.cs | 8 ++++---- .../engine/interpreter/LightCompiler.cs | 2 +- .../engine/parser/SemanticChecks.cs | 4 ++-- .../engine/serialization.cs | 8 ++++---- .../help/MamlCommandHelpInfo.cs | 4 ++-- src/System.Management.Automation/help/MamlNode.cs | 2 +- .../help/UpdatableHelpCommandBase.cs | 2 +- 12 files changed, 24 insertions(+), 30 deletions(-) diff --git a/global.json b/global.json index 8f4a0391bfd..358b066ee15 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "8.0.100-preview.4.23260.5" + "version": "8.0.100-preview.6.23330.14" } } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs index f1f003f37d0..95b25e4e4d5 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs @@ -734,7 +734,7 @@ protected override void ProcessRecord() /// /// Disposes the associated WebSession if it is not being used as part of a persistent session. - /// + /// /// True when called from Dispose() and false when called from finalizer. protected virtual void Dispose(bool disposing) { @@ -752,7 +752,7 @@ protected virtual void Dispose(bool disposing) /// /// Disposes the associated WebSession if it is not being used as part of a persistent session. - /// + /// public void Dispose() { Dispose(disposing: true); @@ -1716,7 +1716,7 @@ internal void ParseLinkHeader(HttpResponseMessage response) /// The Field Value to use. /// The to update. /// If true, collection types in will be enumerated. If false, collections will be treated as single value. - private void AddMultipartContent(object fieldName, object fieldValue, MultipartFormDataContent formData, bool enumerate) + private static void AddMultipartContent(object fieldName, object fieldValue, MultipartFormDataContent formData, bool enumerate) { ArgumentNullException.ThrowIfNull(formData); diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/PendingProgress.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/PendingProgress.cs index 7f1a5ad7e11..b16fb5ee147 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/PendingProgress.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/PendingProgress.cs @@ -458,9 +458,7 @@ internal override /// /// The found node, or null if no suitable node was located. /// - private - ProgressNode - FindOldestNodeOfGivenStyle(ArrayList nodes, int oldestSoFar, ProgressNode.RenderStyle style) + private static ProgressNode FindOldestNodeOfGivenStyle(ArrayList nodes, int oldestSoFar, ProgressNode.RenderStyle style) { if (nodes == null) { @@ -631,9 +629,7 @@ internal override /// /// The PSHostRawUserInterface used to gauge string widths in the rendering. /// - private - void - RenderHelper(ArrayList strings, ArrayList nodes, int indentation, int maxWidth, PSHostRawUserInterface rawUI) + private static void RenderHelper(ArrayList strings, ArrayList nodes, int indentation, int maxWidth, PSHostRawUserInterface rawUI) { Dbg.Assert(strings != null, "strings should not be null"); Dbg.Assert(nodes != null, "nodes should not be null"); @@ -721,9 +717,7 @@ private int TallyHeight(PSHostRawUserInterface rawUi, int maxHeight, int maxWidt /// /// /// - private - bool - AllNodesHaveGivenStyle(ArrayList nodes, ProgressNode.RenderStyle style) + private static bool AllNodesHaveGivenStyle(ArrayList nodes, ProgressNode.RenderStyle style) { if (nodes == null) { diff --git a/src/System.Management.Automation/engine/Modules/RemoveModuleCommand.cs b/src/System.Management.Automation/engine/Modules/RemoveModuleCommand.cs index 7978e42a5b8..52fa4879f41 100644 --- a/src/System.Management.Automation/engine/Modules/RemoveModuleCommand.cs +++ b/src/System.Management.Automation/engine/Modules/RemoveModuleCommand.cs @@ -291,7 +291,7 @@ private bool ModuleProvidesCurrentSessionDrive(PSModuleInfo module) return false; } - private void GetAllNestedModules(PSModuleInfo module, ref List nestedModulesWithNoCircularReference) + private static void GetAllNestedModules(PSModuleInfo module, ref List nestedModulesWithNoCircularReference) { List nestedModules = new List(); if (module.NestedModules != null && module.NestedModules.Count > 0) diff --git a/src/System.Management.Automation/engine/Modules/ScriptAnalysis.cs b/src/System.Management.Automation/engine/Modules/ScriptAnalysis.cs index 5b11966ff84..9644829a02a 100644 --- a/src/System.Management.Automation/engine/Modules/ScriptAnalysis.cs +++ b/src/System.Management.Automation/engine/Modules/ScriptAnalysis.cs @@ -431,7 +431,7 @@ public override AstVisitAction VisitCommand(CommandAst commandAst) return AstVisitAction.SkipChildren; } - private void ProcessCmdletArguments(object value, Action onEachArgument) + private static void ProcessCmdletArguments(object value, Action onEachArgument) { if (value == null) { diff --git a/src/System.Management.Automation/engine/TypeTable.cs b/src/System.Management.Automation/engine/TypeTable.cs index df1e817b6a4..bffeb9e0ceb 100644 --- a/src/System.Management.Automation/engine/TypeTable.cs +++ b/src/System.Management.Automation/engine/TypeTable.cs @@ -1804,7 +1804,7 @@ internal TypeTableLoadException(ConcurrentBag loadErrors) /// /// /// - [Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")] + [Obsolete("Legacy serialization support is deprecated since .NET 8", DiagnosticId = "SYSLIB0051")] protected TypeTableLoadException(SerializationInfo info, StreamingContext context) { throw new NotSupportedException(); @@ -4098,7 +4098,7 @@ internal PSObject.AdapterSet GetTypeAdapter(Type type) #endif } - private TypeMemberData GetTypeMemberDataFromPSMemberInfo(PSMemberInfo member) + private static TypeMemberData GetTypeMemberDataFromPSMemberInfo(PSMemberInfo member) { var note = member as PSNoteProperty; if (note != null) @@ -4165,7 +4165,7 @@ private TypeMemberData GetTypeMemberDataFromPSMemberInfo(PSMemberInfo member) /// /// /// - private void LoadMembersToTypeData(PSMemberInfo member, TypeData typeData) + private static void LoadMembersToTypeData(PSMemberInfo member, TypeData typeData) { Dbg.Assert(member != null, "caller should guarantee that member is not null"); Dbg.Assert(typeData != null, "caller should guarantee that typeData is not null"); @@ -4201,7 +4201,7 @@ private static T GetParameterType(object sourceValue) /// /// Load the standard members into the passed-in TypeData. /// - private void LoadStandardMembersToTypeData(PSMemberSet memberSet, TypeData typeData) + private static void LoadStandardMembersToTypeData(PSMemberSet memberSet, TypeData typeData) { foreach (PSMemberInfo member in memberSet.InternalMembers) { diff --git a/src/System.Management.Automation/engine/interpreter/LightCompiler.cs b/src/System.Management.Automation/engine/interpreter/LightCompiler.cs index e95fa2e3f30..a006b7e0f4f 100644 --- a/src/System.Management.Automation/engine/interpreter/LightCompiler.cs +++ b/src/System.Management.Automation/engine/interpreter/LightCompiler.cs @@ -1357,7 +1357,7 @@ private void CompileThrowUnaryExpression(Expression expr, bool asVoid) } // TODO: remove (replace by true fault support) - private bool EndsWithRethrow(Expression expr) + private static bool EndsWithRethrow(Expression expr) { if (expr.NodeType == ExpressionType.Throw) { diff --git a/src/System.Management.Automation/engine/parser/SemanticChecks.cs b/src/System.Management.Automation/engine/parser/SemanticChecks.cs index 6201e9a9382..b108e6330b4 100644 --- a/src/System.Management.Automation/engine/parser/SemanticChecks.cs +++ b/src/System.Management.Automation/engine/parser/SemanticChecks.cs @@ -553,7 +553,7 @@ public override AstVisitAction VisitTryStatement(TryStatementAst tryStatementAst break; } - if (block2.IsCatchAll) + if (block2.IsCatchAll) { continue; } @@ -1033,7 +1033,7 @@ public override AstVisitAction VisitUsingExpression(UsingExpressionAst usingExpr return AstVisitAction.Continue; } - private ExpressionAst CheckUsingExpression(ExpressionAst exprAst) + private static ExpressionAst CheckUsingExpression(ExpressionAst exprAst) { RuntimeHelpers.EnsureSufficientExecutionStack(); if (exprAst is VariableExpressionAst) diff --git a/src/System.Management.Automation/engine/serialization.cs b/src/System.Management.Automation/engine/serialization.cs index d0c4a30bf3c..8c05240ecf0 100644 --- a/src/System.Management.Automation/engine/serialization.cs +++ b/src/System.Management.Automation/engine/serialization.cs @@ -6007,7 +6007,7 @@ private static string VerifyKey(object key) typeof(PSPrimitiveDictionary) }; - private void VerifyValue(object value) + private static void VerifyValue(object value) { // null is a primitive type if (value == null) @@ -6065,7 +6065,7 @@ private void VerifyValue(object value) public override void Add(object key, object value) { string keyAsString = VerifyKey(key); - this.VerifyValue(value); + VerifyValue(value); base.Add(keyAsString, value); } @@ -6093,7 +6093,7 @@ public override object this[object key] set { string keyAsString = VerifyKey(key); - this.VerifyValue(value); + VerifyValue(value); base[keyAsString] = value; } } @@ -6121,7 +6121,7 @@ public object this[string key] set { - this.VerifyValue(value); + VerifyValue(value); base[key] = value; } } diff --git a/src/System.Management.Automation/help/MamlCommandHelpInfo.cs b/src/System.Management.Automation/help/MamlCommandHelpInfo.cs index d1c52e66cc7..8ae7b0a32cd 100644 --- a/src/System.Management.Automation/help/MamlCommandHelpInfo.cs +++ b/src/System.Management.Automation/help/MamlCommandHelpInfo.cs @@ -315,7 +315,7 @@ internal MamlCommandHelpInfo MergeProviderSpecificHelp(PSObject cmdletHelp, PSOb /// Name of the property for which text needs to be extracted. /// /// - private string ExtractTextForHelpProperty(PSObject psObject, string propertyName) + private static string ExtractTextForHelpProperty(PSObject psObject, string propertyName) { if (psObject == null) return string.Empty; @@ -336,7 +336,7 @@ private string ExtractTextForHelpProperty(PSObject psObject, string propertyName /// /// /// - private string ExtractText(PSObject psObject) + private static string ExtractText(PSObject psObject) { if (psObject == null) { diff --git a/src/System.Management.Automation/help/MamlNode.cs b/src/System.Management.Automation/help/MamlNode.cs index 4abb80b1397..ecf565c942b 100644 --- a/src/System.Management.Automation/help/MamlNode.cs +++ b/src/System.Management.Automation/help/MamlNode.cs @@ -321,7 +321,7 @@ private Hashtable GetInsideProperties(XmlNode xmlNode) /// /// Node whose children are verified for maml. /// - private void RemoveUnsupportedNodes(XmlNode xmlNode) + private static void RemoveUnsupportedNodes(XmlNode xmlNode) { // Start with the first child.. // We want to modify only children.. diff --git a/src/System.Management.Automation/help/UpdatableHelpCommandBase.cs b/src/System.Management.Automation/help/UpdatableHelpCommandBase.cs index 21d0609a353..85d7b3a81c4 100644 --- a/src/System.Management.Automation/help/UpdatableHelpCommandBase.cs +++ b/src/System.Management.Automation/help/UpdatableHelpCommandBase.cs @@ -797,7 +797,7 @@ internal IEnumerable ResolvePath(string path, bool recurse, bool isLiter /// /// Path to resolve. /// A list of directories. - private IEnumerable RecursiveResolvePathHelper(string path) + private static IEnumerable RecursiveResolvePathHelper(string path) { if (System.IO.Directory.Exists(path)) { From dcdad93cf450fd00c12c960adaa9c33983bbc887 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 17 Jul 2023 14:26:07 -0700 Subject: [PATCH 02/12] change method to static --- .../engine/ComInterop/VarEnumSelector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/ComInterop/VarEnumSelector.cs b/src/System.Management.Automation/engine/ComInterop/VarEnumSelector.cs index bbe65d0a6ef..7da63bd1cee 100644 --- a/src/System.Management.Automation/engine/ComInterop/VarEnumSelector.cs +++ b/src/System.Management.Automation/engine/ComInterop/VarEnumSelector.cs @@ -352,7 +352,7 @@ private static bool TryGetPrimitiveComTypeViaConversion(Type argumentType, out V // We will try VT_DISPATCH and then call GetNativeVariantForObject. private const VarEnum VT_DEFAULT = VarEnum.VT_RECORD; - private VarEnum GetComType(ref Type argumentType) + private static VarEnum GetComType(ref Type argumentType) { if (argumentType == typeof(Missing)) { From 81ba66fc5fb6faae426a6cc0869c56e06971b9d3 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 17 Jul 2023 14:34:50 -0700 Subject: [PATCH 03/12] remove win-arm builds --- .vsts-ci/windows/windows-packaging.yml | 5 ----- tools/releaseBuild/azureDevOps/releaseBuild.yml | 9 --------- tools/releaseBuild/azureDevOps/vpackRelease.yml | 4 ---- 3 files changed, 18 deletions(-) diff --git a/.vsts-ci/windows/windows-packaging.yml b/.vsts-ci/windows/windows-packaging.yml index 4a7c9f81fdb..d0e3c101081 100644 --- a/.vsts-ci/windows/windows-packaging.yml +++ b/.vsts-ci/windows/windows-packaging.yml @@ -80,11 +80,6 @@ stages: parameters: channel: preview architecture: x86 - - template: templates/windows-packaging.yml - parameters: - channel: preview - architecture: arm - runtimePrefix: win - template: templates/windows-packaging.yml parameters: channel: preview diff --git a/tools/releaseBuild/azureDevOps/releaseBuild.yml b/tools/releaseBuild/azureDevOps/releaseBuild.yml index 1bab67a0a8b..35c1d0cec01 100644 --- a/tools/releaseBuild/azureDevOps/releaseBuild.yml +++ b/tools/releaseBuild/azureDevOps/releaseBuild.yml @@ -108,10 +108,6 @@ stages: parameters: Architecture: x86 - - template: templates/windows-hosted-build.yml - parameters: - Architecture: arm - - template: templates/windows-hosted-build.yml parameters: Architecture: arm64 @@ -304,11 +300,6 @@ stages: Architecture: x86 parentJob: build_windows_x86_release - - template: templates/windows-packaging.yml - parameters: - Architecture: arm - parentJob: build_windows_arm_release - - template: templates/windows-packaging.yml parameters: Architecture: arm64 diff --git a/tools/releaseBuild/azureDevOps/vpackRelease.yml b/tools/releaseBuild/azureDevOps/vpackRelease.yml index 87b26d3e6dc..e9d1fb286cf 100644 --- a/tools/releaseBuild/azureDevOps/vpackRelease.yml +++ b/tools/releaseBuild/azureDevOps/vpackRelease.yml @@ -61,10 +61,6 @@ stages: parameters: architecture: x86 - - template: ./templates/vpackReleaseJob.yml - parameters: - architecture: arm32 - - template: ./templates/vpackReleaseJob.yml parameters: architecture: arm64 From 27509bc24fa22374f87beffb724ae186a35b3b7a Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 17 Jul 2023 14:55:48 -0700 Subject: [PATCH 04/12] change constructor to public as required by .NET 8 --- .../engine/ComInterop/VarEnumSelector.cs | 2 +- .../engine/Interop/Windows/FindFirstFile.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/System.Management.Automation/engine/ComInterop/VarEnumSelector.cs b/src/System.Management.Automation/engine/ComInterop/VarEnumSelector.cs index 7da63bd1cee..a9e1594ae1c 100644 --- a/src/System.Management.Automation/engine/ComInterop/VarEnumSelector.cs +++ b/src/System.Management.Automation/engine/ComInterop/VarEnumSelector.cs @@ -431,7 +431,7 @@ private static VarEnum GetComType(ref Type argumentType) /// /// Get the COM Variant type that argument should be marshalled as for a call to COM. /// - private VariantBuilder GetVariantBuilder(Type argumentType) + private static VariantBuilder GetVariantBuilder(Type argumentType) { //argumentType is coming from MarshalType, null means the dynamic object holds //a null value and not byref diff --git a/src/System.Management.Automation/engine/Interop/Windows/FindFirstFile.cs b/src/System.Management.Automation/engine/Interop/Windows/FindFirstFile.cs index 1873ada4bf4..abc4dcf5b9d 100644 --- a/src/System.Management.Automation/engine/Interop/Windows/FindFirstFile.cs +++ b/src/System.Management.Automation/engine/Interop/Windows/FindFirstFile.cs @@ -41,7 +41,7 @@ internal unsafe struct WIN32_FIND_DATA internal sealed class SafeFindHandle : SafeHandleZeroOrMinusOneIsInvalid { - private SafeFindHandle() : base(true) { } + public SafeFindHandle() : base(true) { } protected override bool ReleaseHandle() { From d83a4f8f2b06bea2950d6388fa9d4b845e5941a4 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 17 Jul 2023 15:18:35 -0700 Subject: [PATCH 05/12] update version of newtonsoft --- test/perf/dotnet-tools/ResultsComparer/ResultsComparer.csproj | 2 +- test/tools/TestAlc/nested/Test.Isolated.Nested.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/perf/dotnet-tools/ResultsComparer/ResultsComparer.csproj b/test/perf/dotnet-tools/ResultsComparer/ResultsComparer.csproj index f63f5adde24..65ae66d15da 100644 --- a/test/perf/dotnet-tools/ResultsComparer/ResultsComparer.csproj +++ b/test/perf/dotnet-tools/ResultsComparer/ResultsComparer.csproj @@ -8,7 +8,7 @@ - + diff --git a/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj b/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj index 2f4a64332b9..3745b6cdd65 100644 --- a/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj +++ b/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj @@ -16,7 +16,7 @@ - + From ac5a92d23bda49c4d573787edfe70b7db5235bfc Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 17 Jul 2023 16:30:39 -0700 Subject: [PATCH 06/12] change alc test module back to 10.x, but need to rev due to security issue --- test/powershell/engine/Module/IsolatedModule.Tests.ps1 | 5 +++-- test/tools/TestAlc/nested/Test.Isolated.Nested.csproj | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/powershell/engine/Module/IsolatedModule.Tests.ps1 b/test/powershell/engine/Module/IsolatedModule.Tests.ps1 index 5d1289271de..15ac8eaa57e 100644 --- a/test/powershell/engine/Module/IsolatedModule.Tests.ps1 +++ b/test/powershell/engine/Module/IsolatedModule.Tests.ps1 @@ -27,10 +27,11 @@ Describe "Isolated module scenario - load the whole module in custom ALC" -Tag ' $context1.Name | Should -BeExactly "MyCustomALC" $context1 | Should -Be $context2 - ## Test-NestedCommand depends on NewtonSoft.Json 10.0.0.0 while PowerShell depends on 13.0.0.0 or higher. + ## Test-NestedCommand depends on NewtonSoft.Json 10.0.3.0 while PowerShell depends on 13.0.0.0 or higher. ## The exact version of NewtonSoft.Json should be loaded to the custom ALC. $foo = [Test.Isolated.Nested.Foo]::new("Hello", "World") - Test-NestedCommand -Param $foo | Should -BeExactly "Hello-World-Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" + $version = Test-NestedCommand -Param $foo + $version | Should -BeExactly "Hello-World-Newtonsoft.Json, Version=10.0.3.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" -Because $version ## The type 'Test.Isolated.Root.Red' from the root module can be resolved and should be from the same load context. $context3 = [System.Runtime.Loader.AssemblyLoadContext]::GetLoadContext($rootCmd.ImplementingType.Assembly) diff --git a/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj b/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj index 3745b6cdd65..02c60c2a1c8 100644 --- a/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj +++ b/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj @@ -16,7 +16,7 @@ - + From 8d4ab288945fba5d37753e868790913ac98a9af3 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 17 Jul 2023 16:35:08 -0700 Subject: [PATCH 07/12] add a comment on a change --- .../engine/Interop/Windows/FindFirstFile.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/System.Management.Automation/engine/Interop/Windows/FindFirstFile.cs b/src/System.Management.Automation/engine/Interop/Windows/FindFirstFile.cs index abc4dcf5b9d..e53b0985cb6 100644 --- a/src/System.Management.Automation/engine/Interop/Windows/FindFirstFile.cs +++ b/src/System.Management.Automation/engine/Interop/Windows/FindFirstFile.cs @@ -41,6 +41,7 @@ internal unsafe struct WIN32_FIND_DATA internal sealed class SafeFindHandle : SafeHandleZeroOrMinusOneIsInvalid { + // .NET 8 requires the default constructor to be public public SafeFindHandle() : base(true) { } protected override bool ReleaseHandle() From 94e654092b208fc709c9e6c737ffc4c5ee451c10 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 17 Jul 2023 16:47:26 -0700 Subject: [PATCH 08/12] need newtonsoft to be 13.0.1 or newer --- test/powershell/engine/Module/IsolatedModule.Tests.ps1 | 2 +- test/tools/TestAlc/nested/Test.Isolated.Nested.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/powershell/engine/Module/IsolatedModule.Tests.ps1 b/test/powershell/engine/Module/IsolatedModule.Tests.ps1 index 15ac8eaa57e..7a56324f914 100644 --- a/test/powershell/engine/Module/IsolatedModule.Tests.ps1 +++ b/test/powershell/engine/Module/IsolatedModule.Tests.ps1 @@ -31,7 +31,7 @@ Describe "Isolated module scenario - load the whole module in custom ALC" -Tag ' ## The exact version of NewtonSoft.Json should be loaded to the custom ALC. $foo = [Test.Isolated.Nested.Foo]::new("Hello", "World") $version = Test-NestedCommand -Param $foo - $version | Should -BeExactly "Hello-World-Newtonsoft.Json, Version=10.0.3.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" -Because $version + $version | Should -BeExactly "Hello-World-Newtonsoft.Json, Version=13.0.1.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" -Because $version ## The type 'Test.Isolated.Root.Red' from the root module can be resolved and should be from the same load context. $context3 = [System.Runtime.Loader.AssemblyLoadContext]::GetLoadContext($rootCmd.ImplementingType.Assembly) diff --git a/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj b/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj index 02c60c2a1c8..725387f6ead 100644 --- a/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj +++ b/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj @@ -16,7 +16,7 @@ - + From 3e8b88f923d28ad18e9db23bf8cf54e12da584b9 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 17 Jul 2023 17:23:13 -0700 Subject: [PATCH 09/12] change ALC test to use location instead of version --- test/powershell/engine/Module/IsolatedModule.Tests.ps1 | 9 +++++---- test/tools/TestAlc/nested/NestedCommand.cs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/powershell/engine/Module/IsolatedModule.Tests.ps1 b/test/powershell/engine/Module/IsolatedModule.Tests.ps1 index 7a56324f914..ba5a78a8d70 100644 --- a/test/powershell/engine/Module/IsolatedModule.Tests.ps1 +++ b/test/powershell/engine/Module/IsolatedModule.Tests.ps1 @@ -11,7 +11,7 @@ Describe "Isolated module scenario - load the whole module in custom ALC" -Tag ' ## │ Test.Isolated.Init.dll (contains the custom ALC and code to setup 'Resolving' handler) ## │ ## └───Dependencies - ## Newtonsoft.Json.dll (version 10.0.0.0 dependency) + ## Newtonsoft.Json.dll (version 13.0.0.0 dependency) ## Test.Isolated.Nested.dll (nested binary module) ## Test.Isolated.Root.dll (root binary module) $module = Import-Module IsolatedModule -PassThru @@ -27,11 +27,12 @@ Describe "Isolated module scenario - load the whole module in custom ALC" -Tag ' $context1.Name | Should -BeExactly "MyCustomALC" $context1 | Should -Be $context2 - ## Test-NestedCommand depends on NewtonSoft.Json 10.0.3.0 while PowerShell depends on 13.0.0.0 or higher. + ## Test-NestedCommand depends on NewtonSoft.Json 13.0.1.0 while PowerShell depends on 13.0.3.0 or higher. ## The exact version of NewtonSoft.Json should be loaded to the custom ALC. $foo = [Test.Isolated.Nested.Foo]::new("Hello", "World") - $version = Test-NestedCommand -Param $foo - $version | Should -BeExactly "Hello-World-Newtonsoft.Json, Version=13.0.1.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" -Because $version + $location = Test-NestedCommand -Param $foo + $pathSeparator = [System.IO.Path]::DirectorySeparatorChar + $location | Should -BeLikeExactly "*${pathSeparator}test${pathSeparator}tools${pathSeparator}Modules${pathSeparator}IsolatedModule${pathSeparator}Dependencies${pathSeparator}Newtonsoft.Json.dll" ## The type 'Test.Isolated.Root.Red' from the root module can be resolved and should be from the same load context. $context3 = [System.Runtime.Loader.AssemblyLoadContext]::GetLoadContext($rootCmd.ImplementingType.Assembly) diff --git a/test/tools/TestAlc/nested/NestedCommand.cs b/test/tools/TestAlc/nested/NestedCommand.cs index 88822920138..50dda2cfea9 100644 --- a/test/tools/TestAlc/nested/NestedCommand.cs +++ b/test/tools/TestAlc/nested/NestedCommand.cs @@ -14,7 +14,7 @@ public class TestNestedCommand : PSCmdlet protected override void ProcessRecord() { - WriteObject($"{Param.Name}-{Param.Path}-{typeof(StringEscapeHandling).Assembly.FullName}"); + WriteObject($"{Param.Name}-{Param.Path}-{typeof(StringEscapeHandling).Assembly.Location}"); } } From 4d4fc3772f2ddf8f5462b9db6a4e855362a20677 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 7 Aug 2023 12:28:05 -0700 Subject: [PATCH 10/12] revert ALC test chages --- test/powershell/engine/Module/IsolatedModule.Tests.ps1 | 8 +++----- test/tools/TestAlc/nested/Test.Isolated.Nested.csproj | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/test/powershell/engine/Module/IsolatedModule.Tests.ps1 b/test/powershell/engine/Module/IsolatedModule.Tests.ps1 index ba5a78a8d70..5d1289271de 100644 --- a/test/powershell/engine/Module/IsolatedModule.Tests.ps1 +++ b/test/powershell/engine/Module/IsolatedModule.Tests.ps1 @@ -11,7 +11,7 @@ Describe "Isolated module scenario - load the whole module in custom ALC" -Tag ' ## │ Test.Isolated.Init.dll (contains the custom ALC and code to setup 'Resolving' handler) ## │ ## └───Dependencies - ## Newtonsoft.Json.dll (version 13.0.0.0 dependency) + ## Newtonsoft.Json.dll (version 10.0.0.0 dependency) ## Test.Isolated.Nested.dll (nested binary module) ## Test.Isolated.Root.dll (root binary module) $module = Import-Module IsolatedModule -PassThru @@ -27,12 +27,10 @@ Describe "Isolated module scenario - load the whole module in custom ALC" -Tag ' $context1.Name | Should -BeExactly "MyCustomALC" $context1 | Should -Be $context2 - ## Test-NestedCommand depends on NewtonSoft.Json 13.0.1.0 while PowerShell depends on 13.0.3.0 or higher. + ## Test-NestedCommand depends on NewtonSoft.Json 10.0.0.0 while PowerShell depends on 13.0.0.0 or higher. ## The exact version of NewtonSoft.Json should be loaded to the custom ALC. $foo = [Test.Isolated.Nested.Foo]::new("Hello", "World") - $location = Test-NestedCommand -Param $foo - $pathSeparator = [System.IO.Path]::DirectorySeparatorChar - $location | Should -BeLikeExactly "*${pathSeparator}test${pathSeparator}tools${pathSeparator}Modules${pathSeparator}IsolatedModule${pathSeparator}Dependencies${pathSeparator}Newtonsoft.Json.dll" + Test-NestedCommand -Param $foo | Should -BeExactly "Hello-World-Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" ## The type 'Test.Isolated.Root.Red' from the root module can be resolved and should be from the same load context. $context3 = [System.Runtime.Loader.AssemblyLoadContext]::GetLoadContext($rootCmd.ImplementingType.Assembly) diff --git a/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj b/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj index 725387f6ead..2f4a64332b9 100644 --- a/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj +++ b/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj @@ -16,7 +16,7 @@ - + From 0eeede141c2f3881d28a3bd09eb5adf5189430c8 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 7 Aug 2023 12:30:07 -0700 Subject: [PATCH 11/12] missed one file --- test/tools/TestAlc/nested/NestedCommand.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tools/TestAlc/nested/NestedCommand.cs b/test/tools/TestAlc/nested/NestedCommand.cs index 50dda2cfea9..88822920138 100644 --- a/test/tools/TestAlc/nested/NestedCommand.cs +++ b/test/tools/TestAlc/nested/NestedCommand.cs @@ -14,7 +14,7 @@ public class TestNestedCommand : PSCmdlet protected override void ProcessRecord() { - WriteObject($"{Param.Name}-{Param.Path}-{typeof(StringEscapeHandling).Assembly.Location}"); + WriteObject($"{Param.Name}-{Param.Path}-{typeof(StringEscapeHandling).Assembly.FullName}"); } } From e3b9601a404ddd5dcddc59b85d7860864b7d08a0 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Mon, 7 Aug 2023 13:58:51 -0700 Subject: [PATCH 12/12] Supress the NuGet audit warning --- test/tools/TestAlc/nested/Test.Isolated.Nested.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj b/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj index 2f4a64332b9..0a4c741c0cc 100644 --- a/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj +++ b/test/tools/TestAlc/nested/Test.Isolated.Nested.csproj @@ -9,6 +9,7 @@ false + NU1902 ..\..\Modules\IsolatedModule\Dependencies