Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ public override AssemblyName GetName(bool copiedName)

an.RawFlags = GetFlags() | AssemblyNameFlags.PublicKey;

#pragma warning disable IL3000 // System.Reflection.AssemblyName.CodeBase' always returns an empty string for assemblies embedded in a single-file app.
#pragma warning disable IL3000, SYSLIB0044 // System.Reflection.AssemblyName.CodeBase' always returns an empty string for assemblies embedded in a single-file app.
an.CodeBase = GetCodeBase();
#pragma warning restore IL3000
#pragma warning restore IL3000, SYSLIB004 // AssemblyName.CodeBase and AssemblyName.EscapedCodeBase are obsolete, using them for loading an assembly is not supported.

#pragma warning disable SYSLIB0037 // AssemblyName.HashAlgorithm is obsolete
an.HashAlgorithm = GetHashAlgorithm();
Expand Down
3 changes: 3 additions & 0 deletions src/libraries/Common/src/System/Obsoletions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,8 @@ internal static class Obsoletions

internal const string EcDhPublicKeyBlobMessage = "ECDiffieHellmanPublicKey.ToByteArray() and the associated constructor do not have a consistent and interoperable implementation on all platforms. Use ECDiffieHellmanPublicKey.ExportSubjectPublicKeyInfo() instead.";
internal const string EcDhPublicKeyBlobDiagId = "SYSLIB0043";

internal const string AssemblyNameCodeBaseMessage = "AssemblyName.CodeBase and AssemblyName.EscapedCodeBase are obsolete, using them for loading an assembly is not supported.";
internal const string AssemblyNameCodeBaseDiagId = "SYSLIB0044";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,9 @@ private static Assembly LoadAssembly(string codeBase)
catch (ArgumentException)
{
assemblyName = new AssemblyName();
#pragma warning disable SYSLIB0044 // AssemblyName.CodeBase and AssemblyName.EscapedCodeBase are obsolete, using them for loading an assembly is not supported.
assemblyName.CodeBase = codeBase;
#pragma warning restore SYSLIB0044
}

try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,15 @@ public string? CultureName
set => _cultureInfo = (value == null) ? null : new CultureInfo(value);
}

[Obsolete(Obsoletions.AssemblyNameCodeBaseMessage, DiagnosticId = Obsoletions.AssemblyNameCodeBaseDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public string? CodeBase
{
[RequiresAssemblyFiles("The code will return an empty string for assemblies embedded in a single-file app")]
get => _codeBase;
set => _codeBase = value;
}

[Obsolete(Obsoletions.AssemblyNameCodeBaseMessage, DiagnosticId = Obsoletions.AssemblyNameCodeBaseDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[RequiresAssemblyFiles("The code will return an empty string for assemblies embedded in a single-file app")]
public string? EscapedCodeBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ internal void InitAssemblyMethods(XmlMapping[] xmlMappings)
serializerName = Compiler.GetTempAssemblyName(name, defaultNamespace);
// use strong name
name.Name = serializerName;
name.CodeBase = null;
name.CultureInfo = CultureInfo.InvariantCulture;

try
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10828,11 +10828,13 @@ public sealed partial class AssemblyName : System.ICloneable, System.Runtime.Ser
{
public AssemblyName() { }
public AssemblyName(string assemblyName) { }
[System.ObsoleteAttribute("AssemblyName.CodeBase and AssemblyName.EscapedCodeBase are obsolete, using them for loading an assembly is not supported.", DiagnosticId = "SYSLIB0044", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
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("The code will return an empty string for assemblies embedded in a single-file app")]
[System.ObsoleteAttribute("AssemblyName.CodeBase and AssemblyName.EscapedCodeBase are obsolete, using them for loading an assembly is not supported.", DiagnosticId = "SYSLIB0044", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public string? EscapedCodeBase { get { throw null; } }
public System.Reflection.AssemblyNameFlags Flags { get { throw null; } set { } }
public string FullName { get { throw null; } }
Expand Down