Skip to content

Commit 84b88e7

Browse files
Obsolete SuppressIldasmAttribute and remove ildasm.exe support for it (#50951)
1 parent 5b57479 commit 84b88e7

File tree

9 files changed

+15
-38
lines changed

9 files changed

+15
-38
lines changed

docs/project/list-of-diagnostics.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ The PR that reveals the implementation of the `<IncludeInternalObsoleteAttribute
6969
| __`SYSLIB0012`__ | Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location instead. |
7070
| __`SYSLIB0013`__ | Uri.EscapeUriString can corrupt the Uri string in some cases. Consider using Uri.EscapeDataString for query string components instead. |
7171
| __`SYSLIB0014`__ | WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead. |
72-
| __`SYSLIB0015`__ | DisablePrivateReflectionAttribute has no effect in .NET 6.0+ applications. |
72+
| __`SYSLIB0015`__ | DisablePrivateReflectionAttribute has no effect in .NET 6.0+. |
7373
| __`SYSLIB0016`__ | Use the Graphics.GetContextInfo overloads that accept arguments for better performance and fewer allocations. |
7474
| __`SYSLIB0017`__ | Strong name signing is not supported and throws PlatformNotSupportedException. |
7575
| __`SYSLIB0018`__ | ReflectionOnly loading is not supported and throws PlatformNotSupportedException. |
@@ -79,6 +79,7 @@ The PR that reveals the implementation of the `<IncludeInternalObsoleteAttribute
7979
| __`SYSLIB0022`__ | The Rijndael and RijndaelManaged types are obsolete. Use Aes instead. |
8080
| __`SYSLIB0023`__ | RNGCryptoServiceProvider is obsolete. To generate a random number, use one of the RandomNumberGenerator static methods instead. |
8181
| __`SYSLIB0024`__ | Creating and unloading AppDomains is not supported and throws an exception. |
82+
| __`SYSLIB0025`__ | SuppressIldasmAttribute has no effect in .NET 6.0+. |
8283

8384
## Analyzer Warnings
8485

src/coreclr/ildasm/dasm.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -879,22 +879,6 @@ BOOL EnumClasses()
879879
#pragma warning(pop)
880880
#endif
881881

882-
#ifndef _DEBUG
883-
bool HasSuppressingAttribute()
884-
{
885-
const void* pData;
886-
ULONG cbData;
887-
888-
return ((S_OK == g_pImport->GetCustomAttributeByName(TokenFromRid(mdtModule,1),
889-
(LPCUTF8)"System.Runtime.CompilerServices.SuppressIldasmAttribute",
890-
&pData,
891-
&cbData))
892-
|| (S_OK == g_pImport->GetCustomAttributeByName(TokenFromRid(mdtAssembly,1),
893-
(LPCUTF8)"System.Runtime.CompilerServices.SuppressIldasmAttribute",
894-
&pData,
895-
&cbData)));
896-
}
897-
#endif
898882
void DumpMscorlib(void* GUICookie)
899883
{
900884
// In the CoreCLR with reference assemblies and redirection it is more difficult to determine if
@@ -7541,17 +7525,6 @@ BOOL DumpFile()
75417525
_ASSERTE(g_rchCA);
75427526
memset(g_rchCA,0,g_uNCA+1);
75437527
}
7544-
#ifndef _DEBUG
7545-
if(HasSuppressingAttribute())
7546-
{
7547-
if (g_fDumpHeader)
7548-
DumpHeader(g_CORHeader,g_pFile);
7549-
if(g_fDumpMetaInfo)
7550-
DumpMetaInfo(g_wszFullInputFile,NULL,g_pFile);
7551-
printError(g_pFile,RstrUTF(IDS_E_SUPPRESSED));
7552-
goto CloseFileAndExit;
7553-
}
7554-
#endif
75557528

75567529
{
75577530
// Dump the CLR header info if requested.
@@ -7814,9 +7787,6 @@ BOOL DumpFile()
78147787
DumpRTFPostfix(g_pFile);
78157788
}
78167789

7817-
#ifndef _DEBUG
7818-
CloseFileAndExit:
7819-
#endif
78207790
if(g_pFile)
78217791
{
78227792
fclose(g_pFile);

src/coreclr/ildasm/dasm.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ BEGIN
246246
IDS_W_CREATEDMRES L"WARNING: managed resource file %s created"
247247
IDS_E_READINGMRES L"ERROR: reading managed resource %s at offset 0x%X"
248248
IDS_RTL L"RTL_False" // change this to RTL_True on Arabic/Hebrew system
249-
IDS_E_SUPPRESSED L"Protected module -- cannot disassemble"
250249
IDS_LEGALCOPYRIGHT L"\251 Microsoft Corporation. All rights reserved."
251250
END
252251

src/coreclr/ildasm/resource.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,8 @@
180180
#define IDS_VERSION 491
181181
#define IDS_W_CREATEDMRES 492
182182
#define IDS_E_READINGMRES 493
183-
#define IDS_E_SUPPRESSED 494
184-
#define IDS_LEGALCOPYRIGHT 495
185-
#define IDS_E_INVALIDRECORD 496
183+
#define IDS_LEGALCOPYRIGHT 494
184+
#define IDS_E_INVALIDRECORD 495
186185

187186
#define IDC_CHECK1 1000
188187
#define IDC_CHECK2 1001

src/libraries/Common/src/System/Obsoletions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ internal static class Obsoletions
5454
internal const string WebRequestMessage = "WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.";
5555
internal const string WebRequestDiagId = "SYSLIB0014";
5656

57-
internal const string DisablePrivateReflectionAttributeMessage = "DisablePrivateReflectionAttribute has no effect in .NET 6.0+ applications.";
57+
internal const string DisablePrivateReflectionAttributeMessage = "DisablePrivateReflectionAttribute has no effect in .NET 6.0+.";
5858
internal const string DisablePrivateReflectionAttributeDiagId = "SYSLIB0015";
5959

6060
internal const string GetContextInfoMessage = "Use the Graphics.GetContextInfo overloads that accept arguments for better performance and fewer allocations.";
@@ -83,5 +83,8 @@ internal static class Obsoletions
8383

8484
internal const string AppDomainCreateUnloadMessage = "Creating and unloading AppDomains is not supported and throws an exception.";
8585
internal const string AppDomainCreateUnloadDiagId = "SYSLIB0024";
86+
87+
internal const string SuppressIldasmAttributeMessage = "SuppressIldasmAttribute has no effect in .NET 6.0+.";
88+
internal const string SuppressIldasmAttributeDiagId = "SYSLIB0025";
8689
}
8790
}

src/libraries/Directory.Build.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
SYSLIB0021: Derived cryptographic types.
2424
SYSLIB0022: Rijndael types.
2525
SYSLIB0023: RNGCryptoServiceProvider.
26+
SYSLIB0025: SuppressIldasmAttribute.
2627
-->
27-
<NoWarn Condition="'$(IsPartialFacadeAssembly)' == 'true'">$(NoWarn);SYSLIB0003;SYSLIB0004;SYSLIB0015;SYSLIB0017;SYSLIB0021;SYSLIB0022;SYSLIB0023</NoWarn>
28+
<NoWarn Condition="'$(IsPartialFacadeAssembly)' == 'true'">$(NoWarn);SYSLIB0003;SYSLIB0004;SYSLIB0015;SYSLIB0017;SYSLIB0021;SYSLIB0022;SYSLIB0023;SYSLIB0025</NoWarn>
2829
<!-- Reset these properties back to blank, since they are defaulted by Microsoft.NET.Sdk -->
2930
<WarningsAsErrors Condition="'$(WarningsAsErrors)' == 'NU1605'" />
3031
<!-- Set the documentation output file globally. -->

src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SuppressIldasmAttribute.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace System.Runtime.CompilerServices
55
{
6+
[Obsolete(Obsoletions.SuppressIldasmAttributeMessage, DiagnosticId = Obsoletions.SuppressIldasmAttributeDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
67
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module)]
78
public sealed class SuppressIldasmAttribute : Attribute
89
{

src/libraries/System.Runtime/ref/System.Runtime.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9571,7 +9571,7 @@ public DependencyAttribute(string dependentAssemblyArgument, System.Runtime.Comp
95719571
public string DependentAssembly { get { throw null; } }
95729572
public System.Runtime.CompilerServices.LoadHint LoadHint { get { throw null; } }
95739573
}
9574-
[System.ObsoleteAttribute("DisablePrivateReflectionAttribute has no effect in .NET 6.0+ applications.", DiagnosticId = "SYSLIB0015", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
9574+
[System.ObsoleteAttribute("DisablePrivateReflectionAttribute has no effect in .NET 6.0+.", DiagnosticId = "SYSLIB0015", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
95759575
[System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)]
95769576
public sealed partial class DisablePrivateReflectionAttribute : System.Attribute
95779577
{
@@ -9855,6 +9855,7 @@ public StrongBox() { }
98559855
public StrongBox(T value) { }
98569856
object? System.Runtime.CompilerServices.IStrongBox.Value { get { throw null; } set { } }
98579857
}
9858+
[System.ObsoleteAttribute("SuppressIldasmAttribute has no effect in .NET 6.0+.", DiagnosticId = "SYSLIB0025", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
98589859
[System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.Module)]
98599860
public sealed partial class SuppressIldasmAttribute : System.Attribute
98609861
{

src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/AttributesTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,13 @@ public static void StringFreezingAttributeTests()
233233
new StringFreezingAttribute();
234234
}
235235

236+
#pragma warning disable SYSLIB0025 // Obsolete: SuppressIldasmAttribute
236237
[Fact]
237238
public static void SuppressIldasmAttributeTests()
238239
{
239240
new SuppressIldasmAttribute();
240241
}
242+
#pragma warning restore SYSLIB0025 // Obsolete: SuppressIldasmAttribute
241243

242244
[Fact]
243245
public static void TypeForwardedFromAttributeTests()

0 commit comments

Comments
 (0)