Skip to content

Commit

Permalink
Mark LoadFrom overload that always throws as obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
agocke committed May 15, 2024
1 parent a930ef5 commit f6e4705
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/coreclr/System.Private.CoreLib/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Internal.Console</Target>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Runtime.CompilerServices.ICastable</Target>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>F:System.Resources.ResourceManager.BaseNameField</Target>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>F:System.Resources.ResourceSet.Reader</Target>
</Suppression>
<Suppression>
<DiagnosticId>CP0015</DiagnosticId>
<Target>M:System.Diagnostics.Tracing.EventSource.Write``1(System.String,``0):[T:System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute]</Target>
Expand Down Expand Up @@ -29,4 +45,10 @@
<DiagnosticId>CP0015</DiagnosticId>
<Target>M:System.Diagnostics.Tracing.EventSource.WriteEventWithRelatedActivityIdCore(System.Int32,System.Guid*,System.Int32,System.Diagnostics.Tracing.EventSource.EventData*):[T:System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute]</Target>
</Suppression>
<Suppression>
<DiagnosticId>CP0016</DiagnosticId>
<Target>M:System.Reflection.Assembly.LoadFrom(System.String,System.Byte[],System.Configuration.Assemblies.AssemblyHashAlgorithm):[T:System.ObsoleteAttribute]</Target>
<Left>ref/net9.0/System.Private.CoreLib.dll</Left>
<Right>lib/net9.0/System.Private.CoreLib.dll</Right>
</Suppression>
</Suppressions>
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 @@ -177,5 +177,8 @@ internal static class Obsoletions

internal const string ArmIntrinsicPerformsUnsignedOperationMessage = "The underlying hardware instruction does not perform a signed saturate narrowing operation, and it always returns an unsigned result. Use the unsigned overload instead.";
internal const string ArmIntrinsicPerformsUnsignedOperationDiagId = "SYSLIB0055";

internal const string LoadFromHashAlgorithmMessage = "LoadFrom with a custom AssemblyHashAlgorithm is obsolete. Use overloads without an AssemblyHashAlgorithm.";
internal const string LoadFromHashAlgorithmDiagId = "SYSLIB0056";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ public static Assembly LoadFrom(string assemblyFile)
}

[RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")]
[Obsolete(Obsoletions.LoadFromHashAlgorithmMessage, DiagnosticId = Obsoletions.LoadFromHashAlgorithmDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public static Assembly LoadFrom(string assemblyFile, byte[]? hashValue, AssemblyHashAlgorithm hashAlgorithm)
{
throw new NotSupportedException(SR.NotSupported_AssemblyLoadFromHash);
Expand Down

0 comments on commit f6e4705

Please sign in to comment.