diff --git a/Directory.Build.targets b/Directory.Build.targets index 742e70c3900..7873b6402e3 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -16,6 +16,11 @@ $(TargetDir)coverage\$(MSBuildProjectName).coverage + + + true + + x64 $(TargetArchitecture) @@ -52,7 +57,7 @@ - $(VSRedistCommonNetCoreSharedFrameworkx6460PackageVersion) diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItem.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItem.cs index 24823636be4..3d0e9aa3bbe 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItem.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItem.cs @@ -6,6 +6,7 @@ using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Runtime.Serialization; using System.Windows.Forms; @@ -556,6 +557,7 @@ public Type GetType(IDesignerHost host) /// locate the type. If reference is true, the given assembly name will be added /// to the designer host's set of references. /// + [UnconditionalSuppressMessage("SingleFile", "IL3002", Justification = "Single-file case is handled")] protected virtual Type GetType(IDesignerHost host, AssemblyName assemblyName, string typeName, bool reference) { ITypeResolutionService ts = null; diff --git a/src/System.Windows.Forms/src/System/Resources/AssemblyNamesTypeResolutionService.cs b/src/System.Windows.Forms/src/System/Resources/AssemblyNamesTypeResolutionService.cs index c92330a78c4..1a58a1bebe6 100644 --- a/src/System.Windows.Forms/src/System/Resources/AssemblyNamesTypeResolutionService.cs +++ b/src/System.Windows.Forms/src/System/Resources/AssemblyNamesTypeResolutionService.cs @@ -6,6 +6,7 @@ using System.Collections; using System.ComponentModel.Design; +using System.Diagnostics.CodeAnalysis; using System.Reflection; namespace System.Resources @@ -29,6 +30,7 @@ public Assembly GetAssembly(AssemblyName name) return GetAssembly(name, true); } + [UnconditionalSuppressMessage("SingleFile", "IL3002", Justification = "Handles single file case")] public Assembly GetAssembly(AssemblyName name, bool throwOnError) { Assembly result = null; @@ -76,6 +78,7 @@ public Assembly GetAssembly(AssemblyName name, bool throwOnError) return result; } + [UnconditionalSuppressMessage("SingleFile", "IL3002", Justification = "Returns null if in a single file")] public string GetPathOfAssembly(AssemblyName name) { return name.CodeBase; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Application.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Application.cs index 7ffad06b721..baf68b4b3d8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Application.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Application.cs @@ -6,6 +6,7 @@ using System.ComponentModel; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Drawing; using System.Globalization; using System.Reflection; @@ -55,9 +56,6 @@ public sealed partial class Application private static readonly object s_eventApplicationExit = new object(); private static readonly object s_eventThreadExit = new object(); - // Constant string used in Application.Restart() - private const string IEEXEC = "ieexec.exe"; - // Defines a new callback delegate type [EditorBrowsable(EditorBrowsableState.Advanced)] public delegate bool MessageLoopCallback(); @@ -819,6 +817,7 @@ internal static void DoEventsModal() /// Enables visual styles for all subsequent and calls. /// Uses the default theming manifest file shipped with the redist. /// + [UnconditionalSuppressMessage("SingleFile", "IL3002", Justification = "Single-file case is handled")] public static void EnableVisualStyles() { // Pull manifest from our resources @@ -951,6 +950,7 @@ internal static void FormActivated(bool modal, bool activated) /// Retrieves the FileVersionInfo associated with the main module for /// the application. /// + [UnconditionalSuppressMessage("SingleFile", "IL3002", Justification = "Single-file case is handled")] private static FileVersionInfo GetAppFileVersionInfo() { lock (s_internalSyncObject) @@ -958,7 +958,7 @@ private static FileVersionInfo GetAppFileVersionInfo() if (s_appFileVersion is null) { Type t = GetAppMainType(); - if (t is not null) + if (t is not null && t.Assembly.Location.Length > 0) { s_appFileVersion = FileVersionInfo.GetVersionInfo(t.Module.FullyQualifiedName); } @@ -1140,21 +1140,6 @@ public static void Restart() Process process = Process.GetCurrentProcess(); Debug.Assert(process is not null); - if (string.Equals(process.MainModule.ModuleName, IEEXEC, StringComparison.OrdinalIgnoreCase)) - { - string clrPath = Path.GetDirectoryName(typeof(object).Module.FullyQualifiedName); - - if (string.Equals(clrPath + "\\" + IEEXEC, process.MainModule.FileName, StringComparison.OrdinalIgnoreCase)) - { - // HRef exe case - hrefExeCase = true; - Exit(); - if (AppDomain.CurrentDomain.GetData("APP_LAUNCH_URL") is string launchUrl) - { - Process.Start(process.MainModule.FileName, launchUrl); - } - } - } if (!hrefExeCase) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlVersionInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlVersionInfo.cs index 8565cbd17b3..99c65eef3a7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlVersionInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlVersionInfo.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Reflection; namespace System.Windows.Forms @@ -25,6 +26,7 @@ internal ControlVersionInfo(Control owner) /// /// The company name associated with the component. /// + [UnconditionalSuppressMessage("SingleFile", "IL3002", Justification = "Single-file case is handled")] internal string CompanyName { get @@ -37,7 +39,7 @@ internal string CompanyName _companyName = ((AssemblyCompanyAttribute)attrs[0]).Company; } - if (_companyName is null || _companyName.Length == 0) + if ((_companyName is null || _companyName.Length == 0) && !OwnerIsInMemoryAssembly) { _companyName = GetFileVersionInfo().CompanyName; if (_companyName is not null) @@ -74,6 +76,7 @@ internal string CompanyName /// /// The product name associated with this component. /// + [UnconditionalSuppressMessage("SingleFile", "IL3002", Justification = "Single-file case is handled")] internal string ProductName { get @@ -86,7 +89,7 @@ internal string ProductName _productName = ((AssemblyProductAttribute)attrs[0]).Product; } - if (_productName is null || _productName.Length == 0) + if ((_productName is null || _productName.Length == 0) && !OwnerIsInMemoryAssembly) { _productName = GetFileVersionInfo().ProductName; if (_productName is not null) @@ -123,6 +126,7 @@ internal string ProductName /// /// The product version associated with this component. /// + [UnconditionalSuppressMessage("SingleFile", "IL3002", Justification = "Single-file case is handled")] internal string ProductVersion { get @@ -137,7 +141,7 @@ internal string ProductVersion } // win32 version info - if (_productVersion is null || _productVersion.Length == 0) + if ((_productVersion is null || _productVersion.Length == 0) && !OwnerIsInMemoryAssembly) { _productVersion = GetFileVersionInfo().ProductVersion; if (_productVersion is not null) @@ -161,6 +165,7 @@ internal string ProductVersion /// Retrieves the FileVersionInfo associated with the main module for /// the component. /// + [RequiresAssemblyFiles("Throws if _owner is an in-memory assembly. Check " + nameof(OwnerIsInMemoryAssembly) + " first")] private FileVersionInfo GetFileVersionInfo() { if (_versionInfo is null) @@ -172,6 +177,9 @@ private FileVersionInfo GetFileVersionInfo() return _versionInfo; } + + //[UnconditionalSuppressMessage("SingleFile", "IL3000")] + private bool OwnerIsInMemoryAssembly => _owner.GetType().Assembly.Location.Length == 0; } } }