From bf014b59dc52544c268496f9631f1916eb5fa5d7 Mon Sep 17 00:00:00 2001 From: Tlakaelel Axayakatl Ceja Date: Wed, 14 Jul 2021 12:09:16 -0700 Subject: [PATCH] Unify Requires Attribute (#55622) Add an overload to RequiresAssemblyFiles to be able to have the same user experience as if using RequiresUnreferencedCode --- .../src/System/Reflection/Emit/AssemblyBuilder.cs | 2 +- .../src/System/Reflection/RuntimeAssembly.cs | 2 +- .../ref/Microsoft.Extensions.DependencyModel.cs | 6 +++--- .../src/DependencyContext.cs | 6 +++--- .../src/DependencyContextLoader.cs | 6 +++--- .../CodeAnalysis/RequiresAssemblyFilesAttribute.cs | 13 ++++++++++++- .../src/System/Reflection/Assembly.cs | 6 +++--- .../src/System/Reflection/AssemblyName.cs | 6 +++--- .../src/System/Reflection/Emit/AssemblyBuilder.cs | 2 +- .../Context/Delegation/DelegatingAssembly.cs | 8 ++++---- .../Reflection/TypeLoading/Assemblies/RoAssembly.cs | 4 ++-- src/libraries/System.Runtime/ref/System.Runtime.cs | 13 +++++++------ .../RequiresAssemblyFilesAttributeTests.cs | 4 ++-- .../src/System/Reflection/RuntimeAssembly.cs | 2 +- 14 files changed, 46 insertions(+), 34 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs index a0faa6ad6e02a..5eea3c9dae6da 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs @@ -104,7 +104,7 @@ public override FileStream[] GetFiles(bool getResourceModules) public override string Location => throw new NotSupportedException(SR.NotSupported_DynamicAssembly); - [RequiresAssemblyFiles(Message = "The code will throw for assemblies embedded in a single-file app")] + [RequiresAssemblyFiles("The code will throw for assemblies embedded in a single-file app")] public override string? CodeBase => throw new NotSupportedException(SR.NotSupported_DynamicAssembly); [RequiresUnreferencedCode("Types might be removed")] diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs index dc866cf6ba374..a45d81d4b2342 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs @@ -83,7 +83,7 @@ private static extern bool GetCodeBase(QCallAssembly assembly, return null; } - [RequiresAssemblyFiles(Message = "The code will throw for assemblies embedded in a single-file app")] + [RequiresAssemblyFiles("The code will throw for assemblies embedded in a single-file app")] public override string? CodeBase { get diff --git a/src/libraries/Microsoft.Extensions.DependencyModel/ref/Microsoft.Extensions.DependencyModel.cs b/src/libraries/Microsoft.Extensions.DependencyModel/ref/Microsoft.Extensions.DependencyModel.cs index 10786ab1afe24..8874af552ba45 100644 --- a/src/libraries/Microsoft.Extensions.DependencyModel/ref/Microsoft.Extensions.DependencyModel.cs +++ b/src/libraries/Microsoft.Extensions.DependencyModel/ref/Microsoft.Extensions.DependencyModel.cs @@ -62,12 +62,12 @@ public partial class DependencyContext public DependencyContext(Microsoft.Extensions.DependencyModel.TargetInfo target, Microsoft.Extensions.DependencyModel.CompilationOptions compilationOptions, System.Collections.Generic.IEnumerable compileLibraries, System.Collections.Generic.IEnumerable runtimeLibraries, System.Collections.Generic.IEnumerable runtimeGraph) { } public Microsoft.Extensions.DependencyModel.CompilationOptions CompilationOptions { get { throw null; } } public System.Collections.Generic.IReadOnlyList CompileLibraries { get { throw null; } } - [System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute(Message = "DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")] + [System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute("DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")] public static Microsoft.Extensions.DependencyModel.DependencyContext Default { get { throw null; } } public System.Collections.Generic.IReadOnlyList RuntimeGraph { get { throw null; } } public System.Collections.Generic.IReadOnlyList RuntimeLibraries { get { throw null; } } public Microsoft.Extensions.DependencyModel.TargetInfo Target { get { throw null; } } - [System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute(Message = "DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")] + [System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute("DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")] public static Microsoft.Extensions.DependencyModel.DependencyContext Load(System.Reflection.Assembly assembly) { throw null; } public Microsoft.Extensions.DependencyModel.DependencyContext Merge(Microsoft.Extensions.DependencyModel.DependencyContext other) { throw null; } } @@ -97,7 +97,7 @@ public partial class DependencyContextLoader { public DependencyContextLoader() { } public static Microsoft.Extensions.DependencyModel.DependencyContextLoader Default { get { throw null; } } - [System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute(Message = "DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")] + [System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute("DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")] public Microsoft.Extensions.DependencyModel.DependencyContext Load(System.Reflection.Assembly assembly) { throw null; } } public partial class DependencyContextWriter diff --git a/src/libraries/Microsoft.Extensions.DependencyModel/src/DependencyContext.cs b/src/libraries/Microsoft.Extensions.DependencyModel/src/DependencyContext.cs index 6e58abf313409..770123f2beb53 100644 --- a/src/libraries/Microsoft.Extensions.DependencyModel/src/DependencyContext.cs +++ b/src/libraries/Microsoft.Extensions.DependencyModel/src/DependencyContext.cs @@ -50,7 +50,7 @@ public DependencyContext(TargetInfo target, RuntimeGraph = runtimeGraph.ToArray(); } - [RequiresAssemblyFiles(Message = "DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")] + [RequiresAssemblyFiles("DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")] public static DependencyContext Default => _defaultContext.Value; public TargetInfo Target { get; } @@ -79,7 +79,7 @@ public DependencyContext Merge(DependencyContext other) ); } - [RequiresAssemblyFiles(Message = "DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")] + [RequiresAssemblyFiles("DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")] private static DependencyContext LoadDefault() { var entryAssembly = Assembly.GetEntryAssembly(); @@ -91,7 +91,7 @@ private static DependencyContext LoadDefault() return Load(entryAssembly); } - [RequiresAssemblyFiles(Message = "DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")] + [RequiresAssemblyFiles("DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")] public static DependencyContext Load(Assembly assembly) { return DependencyContextLoader.Default.Load(assembly); diff --git a/src/libraries/Microsoft.Extensions.DependencyModel/src/DependencyContextLoader.cs b/src/libraries/Microsoft.Extensions.DependencyModel/src/DependencyContextLoader.cs index 2bd5d410d466b..6032c69281ae6 100644 --- a/src/libraries/Microsoft.Extensions.DependencyModel/src/DependencyContextLoader.cs +++ b/src/libraries/Microsoft.Extensions.DependencyModel/src/DependencyContextLoader.cs @@ -51,7 +51,7 @@ private static Stream GetResourceStream(Assembly assembly, string name) return assembly.GetManifestResourceStream(name); } - [RequiresAssemblyFiles(Message = "DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")] + [RequiresAssemblyFiles("DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")] public DependencyContext Load(Assembly assembly) { if (assembly == null) @@ -105,7 +105,7 @@ private DependencyContext LoadContext(IDependencyContextReader reader, string lo return null; } - [RequiresAssemblyFiles(Message = "DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")] + [RequiresAssemblyFiles("DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")] private DependencyContext LoadAssemblyContext(Assembly assembly, IDependencyContextReader reader) { using (Stream stream = GetResourceStream(assembly, assembly.GetName().Name + DepsJsonExtension)) @@ -128,7 +128,7 @@ private DependencyContext LoadAssemblyContext(Assembly assembly, IDependencyCont return null; } - [RequiresAssemblyFiles(Message = "The use of DependencyContextLoader is not supported when publishing as single-file")] + [RequiresAssemblyFiles("The use of DependencyContextLoader is not supported when publishing as single-file")] private string GetDepsJsonPath(Assembly assembly) { // Assemblies loaded in memory (e.g. single file) return empty string from Location. diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/RequiresAssemblyFilesAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/RequiresAssemblyFilesAttribute.cs index 358bf3136da83..9c90c326948af 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/RequiresAssemblyFilesAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/RequiresAssemblyFilesAttribute.cs @@ -24,11 +24,22 @@ sealed class RequiresAssemblyFilesAttribute : Attribute /// public RequiresAssemblyFilesAttribute() { } + /// + /// Initializes a new instance of the class. + /// + /// + /// A message that contains information about the need for assembly files to be on disk. + /// + public RequiresAssemblyFilesAttribute(string message) + { + Message = message; + } + /// /// Gets or sets an optional message that contains information about the need for /// assembly files to be on disk. /// - public string? Message { get; set; } + public string? Message { get; } /// /// Gets or sets an optional URL that contains more information about the member, diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs index 6baab555151b4..5b5035b272062 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs @@ -81,7 +81,7 @@ public virtual IEnumerable ExportedTypes [RequiresUnreferencedCode("Types might be removed")] public virtual Type[] GetForwardedTypes() { throw NotImplemented.ByDesign; } - [RequiresAssemblyFiles(Message = "The code will throw for assemblies embedded in a single-file app")] + [RequiresAssemblyFiles("The code will throw for assemblies embedded in a single-file app")] public virtual string? CodeBase => throw NotImplemented.ByDesign; public virtual MethodInfo? EntryPoint => throw NotImplemented.ByDesign; public virtual string? FullName => throw NotImplemented.ByDesign; @@ -116,7 +116,7 @@ public virtual IEnumerable ExportedTypes public virtual object[] GetCustomAttributes(bool inherit) { throw NotImplemented.ByDesign; } public virtual object[] GetCustomAttributes(Type attributeType, bool inherit) { throw NotImplemented.ByDesign; } - [RequiresAssemblyFiles(Message = "The code will throw for assemblies embedded in a single-file app")] + [RequiresAssemblyFiles("The code will throw for assemblies embedded in a single-file app")] public virtual string EscapedCodeBase => AssemblyName.EscapeCodeBase(CodeBase); [RequiresUnreferencedCode("Assembly.CreateInstance is not supported with trimming. Use Type.GetType instead.")] @@ -154,7 +154,7 @@ public virtual IEnumerable ExportedTypes public virtual Assembly GetSatelliteAssembly(CultureInfo culture, Version? version) { throw NotImplemented.ByDesign; } public virtual FileStream? GetFile(string name) { throw NotImplemented.ByDesign; } - [RequiresAssemblyFiles(Message = "The code will throw for assemblies embedded in a single-file app")] + [RequiresAssemblyFiles("The code will throw for assemblies embedded in a single-file app")] public virtual FileStream[] GetFiles() => GetFiles(getResourceModules: false); public virtual FileStream[] GetFiles(bool getResourceModules) { throw NotImplemented.ByDesign; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs index 4291dded86107..45369f7528e73 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs @@ -60,12 +60,12 @@ public string? CultureName public string? CodeBase { - [RequiresAssemblyFiles(Message = "The code will return an empty string for assemblies embedded in a single-file app")] + [RequiresAssemblyFiles("The code will return an empty string for assemblies embedded in a single-file app")] get => _codeBase; set => _codeBase = value; } - [RequiresAssemblyFiles(Message = "The code will return an empty string for assemblies embedded in a single-file app")] + [RequiresAssemblyFiles("The code will return an empty string for assemblies embedded in a single-file app")] public string? EscapedCodeBase { get @@ -261,7 +261,7 @@ public static bool ReferenceMatchesDefinition(AssemblyName? reference, AssemblyN return refName.Equals(defName, StringComparison.OrdinalIgnoreCase); } - [RequiresAssemblyFiles(Message = "The code will return an empty string for assemblies embedded in a single-file app")] + [RequiresAssemblyFiles("The code will return an empty string for assemblies embedded in a single-file app")] internal static string EscapeCodeBase(string? codebase) { if (codebase == null) diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs index 5dbdeeb3a67b0..dc77c941297f3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs @@ -8,7 +8,7 @@ namespace System.Reflection.Emit { public sealed partial class AssemblyBuilder : Assembly { - [RequiresAssemblyFiles(Message = "The code will throw for assemblies embedded in a single-file app")] + [RequiresAssemblyFiles("The code will throw for assemblies embedded in a single-file app")] public override string? CodeBase => throw new NotSupportedException(SR.NotSupported_DynamicAssembly); public override string Location => throw new NotSupportedException(SR.NotSupported_DynamicAssembly); public override MethodInfo? EntryPoint => null; diff --git a/src/libraries/System.Reflection.Context/src/System/Reflection/Context/Delegation/DelegatingAssembly.cs b/src/libraries/System.Reflection.Context/src/System/Reflection/Context/Delegation/DelegatingAssembly.cs index 990302be8c5f0..dd48ebd0d9e00 100644 --- a/src/libraries/System.Reflection.Context/src/System/Reflection/Context/Delegation/DelegatingAssembly.cs +++ b/src/libraries/System.Reflection.Context/src/System/Reflection/Context/Delegation/DelegatingAssembly.cs @@ -23,7 +23,7 @@ public DelegatingAssembly(Assembly assembly) } #pragma warning disable IL3003 // netstandard2.1 didn't have RequiresAssemblyFiles attributes applied on Assembly - [RequiresAssemblyFiles(Message = "Calling 'System.Reflection.Assembly.Location' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'", Url = "https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/il3000")] + [RequiresAssemblyFiles("Calling 'System.Reflection.Assembly.Location' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'", Url = "https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/il3000")] public override string Location { get { return UnderlyingAssembly.Location; } @@ -111,19 +111,19 @@ public override Type[] GetExportedTypes() } #pragma warning disable IL3003 // netstandard2.1 didn't have RequiresAssemblyFiles attributes applied on Assembly - [RequiresAssemblyFiles(Message = "Calling 'System.Reflection.Assembly.GetFile(string)' will throw for assemblies embedded in a single-file app", Url = "https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/il3001")] + [RequiresAssemblyFiles("Calling 'System.Reflection.Assembly.GetFile(string)' will throw for assemblies embedded in a single-file app", Url = "https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/il3001")] public override FileStream? GetFile(string name) { return UnderlyingAssembly.GetFile(name); } - [RequiresAssemblyFiles(Message = "Calling 'System.Reflection.Assembly.GetFiles()' will throw for assemblies embedded in a single-file app", Url = "https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/il3001")] + [RequiresAssemblyFiles("Calling 'System.Reflection.Assembly.GetFiles()' will throw for assemblies embedded in a single-file app", Url = "https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/il3001")] public override FileStream[] GetFiles() { return UnderlyingAssembly.GetFiles(); } - [RequiresAssemblyFiles(Message = "Calling 'System.Reflection.Assembly.GetFiles(bool)' will throw for assemblies embedded in a single-file app", Url = "https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/il3001")] + [RequiresAssemblyFiles("Calling 'System.Reflection.Assembly.GetFiles(bool)' will throw for assemblies embedded in a single-file app", Url = "https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/il3001")] public override FileStream[] GetFiles(bool getResourceModules) { return UnderlyingAssembly.GetFiles(getResourceModules); diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/RoAssembly.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/RoAssembly.cs index 949994d04b3a9..114f581d06954 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/RoAssembly.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/RoAssembly.cs @@ -44,12 +44,12 @@ protected RoAssembly(MetadataLoadContext loader, int assemblyFileCount) public abstract override string Location { get; } #if NET5_0_OR_GREATER [Obsolete(Obsoletions.CodeBaseMessage, DiagnosticId = Obsoletions.CodeBaseDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] - [RequiresAssemblyFiles(Message = "The code will throw for assemblies embedded in a single-file app")] + [RequiresAssemblyFiles("The code will throw for assemblies embedded in a single-file app")] #endif public sealed override string CodeBase => throw new NotSupportedException(SR.NotSupported_AssemblyCodeBase); #if NET5_0_OR_GREATER [Obsolete(Obsoletions.CodeBaseMessage, DiagnosticId = Obsoletions.CodeBaseDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] - [RequiresAssemblyFiles(Message = "The code will throw for assemblies embedded in a single-file app")] + [RequiresAssemblyFiles("The code will throw for assemblies embedded in a single-file app")] #endif public sealed override string EscapedCodeBase => throw new NotSupportedException(SR.NotSupported_AssemblyCodeBase); diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index b1baaa1a95dba..c18894bd25778 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -9011,7 +9011,8 @@ public NotNullWhenAttribute(bool returnValue) { } public sealed partial class RequiresAssemblyFilesAttribute : System.Attribute { public RequiresAssemblyFilesAttribute() { } - public string? Message { get { throw null; } set { } } + public RequiresAssemblyFilesAttribute(string message) { } + public string? Message { get { throw null; } } public string? Url { get { throw null; } set { } } } [System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Method, Inherited=false)] @@ -11059,13 +11060,13 @@ public abstract partial class Assembly : System.Reflection.ICustomAttributeProvi { protected Assembly() { } [System.ObsoleteAttribute("Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location instead.", DiagnosticId = "SYSLIB0012", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] - [System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute(Message="The code will throw for assemblies embedded in a single-file app")] + [System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute("The code will throw for assemblies embedded in a single-file app")] public virtual string? CodeBase { get { throw null; } } public virtual System.Collections.Generic.IEnumerable CustomAttributes { get { throw null; } } public virtual System.Collections.Generic.IEnumerable DefinedTypes { [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Types might be removed")] get { throw null; } } public virtual System.Reflection.MethodInfo? EntryPoint { get { throw null; } } [System.ObsoleteAttribute("Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location instead.", DiagnosticId = "SYSLIB0012", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] - [System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute(Message="The code will throw for assemblies embedded in a single-file app")] + [System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute("The code will throw for assemblies embedded in a single-file app")] public virtual string EscapedCodeBase { get { throw null; } } public virtual System.Collections.Generic.IEnumerable ExportedTypes { [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Types might be removed")] get { throw null; } } public virtual string? FullName { get { throw null; } } @@ -11100,7 +11101,7 @@ public virtual event System.Reflection.ModuleResolveEventHandler? ModuleResolve [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Types might be removed")] public virtual System.Type[] GetExportedTypes() { throw null; } public virtual System.IO.FileStream? GetFile(string name) { throw null; } - [System.Diagnostics.CodeAnalysis.RequiresAssemblyFiles(Message = "The code will throw for assemblies embedded in a single-file app")] + [System.Diagnostics.CodeAnalysis.RequiresAssemblyFiles("The code will throw for assemblies embedded in a single-file app")] public virtual System.IO.FileStream[] GetFiles() { throw null; } public virtual System.IO.FileStream[] GetFiles(bool getResourceModules) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Types might be removed")] @@ -11269,11 +11270,11 @@ public sealed partial class AssemblyName : System.ICloneable, System.Runtime.Ser { public AssemblyName() { } public AssemblyName(string assemblyName) { } - public string? CodeBase { [System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute(Message = "The code will return an empty string for assemblies embedded in a single-file app")] get { throw null; } set { } } + public string? CodeBase { [System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute("The code will return an empty string for assemblies embedded in a single-file app")] get { throw null; } set { } } public System.Reflection.AssemblyContentType ContentType { get { throw null; } set { } } public System.Globalization.CultureInfo? CultureInfo { get { throw null; } set { } } public string? CultureName { get { throw null; } set { } } - [System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute(Message="The code will return an empty string for assemblies embedded in a single-file app")] + [System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute("The code will return an empty string for assemblies embedded in a single-file app")] public string? EscapedCodeBase { get { throw null; } } public System.Reflection.AssemblyNameFlags Flags { get { throw null; } set { } } public string FullName { get { throw null; } } diff --git a/src/libraries/System.Runtime/tests/System/Diagnostics/CodeAnalysis/RequiresAssemblyFilesAttributeTests.cs b/src/libraries/System.Runtime/tests/System/Diagnostics/CodeAnalysis/RequiresAssemblyFilesAttributeTests.cs index da098f97f5ad6..974de11e89bb9 100644 --- a/src/libraries/System.Runtime/tests/System/Diagnostics/CodeAnalysis/RequiresAssemblyFilesAttributeTests.cs +++ b/src/libraries/System.Runtime/tests/System/Diagnostics/CodeAnalysis/RequiresAssemblyFilesAttributeTests.cs @@ -22,7 +22,7 @@ public void TestConstructor() [InlineData(null)] public void TestSetMessage(string message) { - var attr = new RequiresAssemblyFilesAttribute(Message = message); + var attr = new RequiresAssemblyFilesAttribute(message); Assert.Equal(message, attr.Message); Assert.Null(attr.Url); @@ -52,7 +52,7 @@ public void TestSetUrl(string url) [InlineData(null, null)] public void TestSetMessageAndUrl(string message, string url) { - var attr = new RequiresAssemblyFilesAttribute(Message = message, Url = url); + var attr = new RequiresAssemblyFilesAttribute(message, Url = url); Assert.Equal(message, attr.Message); Assert.Equal(ur, attr.Url); diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs index 21ac12509e6be..cf2511fa28323 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs @@ -74,7 +74,7 @@ public extern override MethodInfo? EntryPoint public override bool ReflectionOnly => false; - [RequiresAssemblyFiles(Message = "The code will throw for assemblies embedded in a single-file app")] + [RequiresAssemblyFiles("The code will throw for assemblies embedded in a single-file app")] public override string? CodeBase { get