From 29a760d4a68ef40919846cf6e89005d6e56fc07e Mon Sep 17 00:00:00 2001 From: Forgind Date: Thu, 30 Mar 2023 10:05:44 -0700 Subject: [PATCH 1/4] Make Unregister a no-op --- src/MSBuildLocator/MSBuildLocator.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/MSBuildLocator/MSBuildLocator.cs b/src/MSBuildLocator/MSBuildLocator.cs index 40b27e81..5a8a0879 100644 --- a/src/MSBuildLocator/MSBuildLocator.cs +++ b/src/MSBuildLocator/MSBuildLocator.cs @@ -290,19 +290,6 @@ Assembly TryLoadAssembly(AssemblyName assemblyName) /// public static void Unregister() { - if (!IsRegistered) - { - var error = $"{typeof(MSBuildLocator)}.{nameof(Unregister)} was called, but no MSBuild instance is registered." + Environment.NewLine + - $"Ensure that {nameof(RegisterInstance)}, {nameof(RegisterMSBuildPath)}, or {nameof(RegisterDefaults)} is called before calling this method." + Environment.NewLine + - $"{nameof(IsRegistered)} should be used to determine whether calling {nameof(Unregister)} is a valid operation."; - throw new InvalidOperationException(error); - } - -#if NET46 - AppDomain.CurrentDomain.AssemblyResolve -= s_registeredHandler; -#else - AssemblyLoadContext.Default.Resolving -= s_registeredHandler; -#endif } /// From 3a7d7178e1cd2dc17710f84e3d822a47a7ec3e5e Mon Sep 17 00:00:00 2001 From: Forgind Date: Thu, 30 Mar 2023 12:27:53 -0700 Subject: [PATCH 2/4] Change comment --- src/MSBuildLocator/MSBuildLocator.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/MSBuildLocator/MSBuildLocator.cs b/src/MSBuildLocator/MSBuildLocator.cs index 5a8a0879..5f838add 100644 --- a/src/MSBuildLocator/MSBuildLocator.cs +++ b/src/MSBuildLocator/MSBuildLocator.cs @@ -283,11 +283,8 @@ Assembly TryLoadAssembly(AssemblyName assemblyName) } /// - /// Remove assembly resolution previously registered via , , or . + /// This has no effect and exists only for backwards compatibility. Calling it is unnecessary. /// - /// - /// This will automatically be called once all supported assemblies are loaded into the current AppDomain and so generally is not necessary to call directly. - /// public static void Unregister() { } From e42b87bbcc75a0d8426ff6728ed7b3879184ed95 Mon Sep 17 00:00:00 2001 From: Forgind Date: Fri, 31 Mar 2023 09:35:02 -0700 Subject: [PATCH 3/4] Specify not to show Unregister --- src/MSBuildLocator/MSBuildLocator.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/MSBuildLocator/MSBuildLocator.cs b/src/MSBuildLocator/MSBuildLocator.cs index 5f838add..869fa7e3 100644 --- a/src/MSBuildLocator/MSBuildLocator.cs +++ b/src/MSBuildLocator/MSBuildLocator.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Reflection; using System.Text; +using System.ComponentModel; #if NETCOREAPP using System.Runtime.Loader; @@ -285,6 +286,7 @@ Assembly TryLoadAssembly(AssemblyName assemblyName) /// /// This has no effect and exists only for backwards compatibility. Calling it is unnecessary. /// + [EditorBrowsable(EditorBrowsableState.Never)] public static void Unregister() { } From 388601c1fe6020af89125e51aac3651e1a898387 Mon Sep 17 00:00:00 2001 From: Forgind Date: Mon, 3 Apr 2023 11:22:53 -0700 Subject: [PATCH 4/4] Sort usings --- src/MSBuildLocator/MSBuildLocator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MSBuildLocator/MSBuildLocator.cs b/src/MSBuildLocator/MSBuildLocator.cs index 869fa7e3..ab435c86 100644 --- a/src/MSBuildLocator/MSBuildLocator.cs +++ b/src/MSBuildLocator/MSBuildLocator.cs @@ -3,12 +3,12 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Text; -using System.ComponentModel; #if NETCOREAPP using System.Runtime.Loader;