Skip to content

Commit e10532a

Browse files
i3arnonjeffhandley
andauthored
Obsolete thumbtacked AssemblyName properties (#59522)
* Obsolete thumbtacked AssemblyName properties Fix #59061 * Ignore obsoletion * Fix pragma * Merge the AssemblyName member obsoletions into a single diagnostic id * Fix pragma to use updated diagnostic id * Suppress SYSLIB0037 in reflection tests * Suppress SYSLIB0037 warnings Co-authored-by: Jeff Handley <[email protected]> Co-authored-by: Jeff Handley <[email protected]>
1 parent 25da88c commit e10532a

File tree

10 files changed

+25
-4
lines changed

10 files changed

+25
-4
lines changed

docs/project/list-of-diagnostics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ The PR that reveals the implementation of the `<IncludeInternalObsoleteAttribute
9191
| __`SYSLIB0034`__ | CmsSigner(CspParameters) is obsolete and is not supported. Use an alternative constructor instead. |
9292
| __`SYSLIB0035`__ | ComputeCounterSignature without specifying a CmsSigner is obsolete and is not supported. Use the overload that accepts a CmsSigner. |
9393
| __`SYSLIB0036`__ | Regex.CompileToAssembly is obsolete and not supported. Use RegexGeneratorAttribute with the regular expression source generator instead. |
94+
| __`SYSLIB0037`__ | AssemblyName members HashAlgorithm, ProcessorArchitecture, and VersionCompatibility are obsolete and not supported. |
9495

9596
## Analyzer Warnings
9697

src/coreclr/System.Private.CoreLib/src/System/Reflection/AssemblyName.CoreCLR.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ internal static AssemblyName GetFileInformationCore(string assemblyFile)
6363

6464
internal void SetProcArchIndex(PortableExecutableKinds pek, ImageFileMachine ifm)
6565
{
66+
#pragma warning disable SYSLIB0037 // AssemblyName.ProcessorArchitecture is obsolete
6667
ProcessorArchitecture = CalculateProcArchIndex(pek, ifm, _flags);
68+
#pragma warning restore SYSLIB0037
6769
}
6870

6971
internal static ProcessorArchitecture CalculateProcArchIndex(PortableExecutableKinds pek, ImageFileMachine ifm, AssemblyNameFlags flags)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,8 @@ internal static class Obsoletions
119119

120120
internal const string RegexCompileToAssemblyMessage = "Regex.CompileToAssembly is obsolete and not supported. Use RegexGeneratorAttribute with the regular expression source generator instead.";
121121
internal const string RegexCompileToAssemblyDiagId = "SYSLIB0036";
122+
123+
internal const string AssemblyNameMembersMessage = "AssemblyName members HashAlgorithm, ProcessorArchitecture, and VersionCompatibility are obsolete and not supported.";
124+
internal const string AssemblyNameMembersDiagId = "SYSLIB0037";
122125
}
123126
}

src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public string? EscapedCodeBase
7777
}
7878
}
7979

80+
[Obsolete(Obsoletions.AssemblyNameMembersMessage, DiagnosticId = Obsoletions.AssemblyNameMembersDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
8081
public ProcessorArchitecture ProcessorArchitecture
8182
{
8283
get
@@ -189,12 +190,14 @@ public AssemblyNameFlags Flags
189190
}
190191
}
191192

193+
[Obsolete(Obsoletions.AssemblyNameMembersMessage, DiagnosticId = Obsoletions.AssemblyNameMembersDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
192194
public AssemblyHashAlgorithm HashAlgorithm
193195
{
194196
get => _hashAlgorithm;
195197
set => _hashAlgorithm = value;
196198
}
197199

200+
[Obsolete(Obsoletions.AssemblyNameMembersMessage, DiagnosticId = Obsoletions.AssemblyNameMembersDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
198201
public AssemblyVersionCompatibility VersionCompatibility
199202
{
200203
get => _versionCompatibility;

src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/MetadataReader.netstandard.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ internal AssemblyName GetAssemblyName(StringHandle nameHandle, Version version,
1616
{
1717
Version = version,
1818
CultureName = cultureName,
19+
#pragma warning disable SYSLIB0037 // AssemblyName.HashAlgorithm is obsolete
1920
HashAlgorithm = hashAlgorithm,
21+
#pragma warning restore
2022
Flags = GetAssemblyNameFlags(flags),
2123
ContentType = GetContentTypeFromAssemblyFlags(flags)
2224
};

src/libraries/System.Reflection.Metadata/tests/System.Reflection.Metadata.Tests.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
<PropertyGroup>
33
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
44
<ExternallyShipping>false</ExternallyShipping>
5-
<NoWarn>436</NoWarn> <!-- Type conflicts on "Interop" due to InternalsVisibleTo access -->
5+
<!-- 436: Type conflicts on "Interop" due to InternalsVisibleTo access
6+
SYSLIB0037: AssemblyName members HashAlgorithm, ProcessorArchitecture, and VersionCompatibility are obsolete. -->
7+
<NoWarn>$(NoWarn);436;SYSLIB0037</NoWarn>
68
<TargetFrameworks>$(NetCoreAppCurrent);$(NetFrameworkMinimum)</TargetFrameworks>
79
<EnableDllImportGenerator>true</EnableDllImportGenerator>
810
</PropertyGroup>

src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/AssemblyNameData.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ public AssemblyName CreateAssemblyName()
3232
Version = Version,
3333
CultureName = CultureName,
3434
ContentType = ContentType,
35+
#pragma warning disable SYSLIB0037 // AssemblyName members HashAlgorithm and ProcessorArchitecture are obsolete
3536
HashAlgorithm = HashAlgorithm,
3637
ProcessorArchitecture = ProcessorArchitecture
38+
#pragma warning restore
3739
};
3840

3941
// Yes, *we* have to clone the array. AssemblyName.SetPublicKey() violates framework guidelines and doesn't make a copy.

src/libraries/System.Reflection.MetadataLoadContext/tests/System.Reflection.MetadataLoadContext.Tests.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
<PropertyGroup>
33
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
44
<TargetFrameworks>$(NetCoreAppCurrent);$(NetFrameworkMinimum)</TargetFrameworks>
5-
<!-- The GAC is obsolete, but there are unit tests still referencing it -->
6-
<NoWarn>$(NoWarn);SYSLIB0005</NoWarn>
5+
<!-- SYSLIB0005: The GAC is obsolete, but there are unit tests still referencing it.
6+
SYSLIB0037: AssemblyName members HashAlgorithm, ProcessorArchitecture, and VersionCompatibility are obsolete. -->
7+
<NoWarn>$(NoWarn);SYSLIB0005;SYSLIB0037</NoWarn>
78
</PropertyGroup>
89
<ItemGroup>
910
<Compile Include="$(CommonTestPath)System\IO\TempDirectory.cs"

src/libraries/System.Reflection/tests/System.Reflection.Tests.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
<!-- LoadFrom_SameIdentityAsAssemblyWithDifferentPath_ReturnsEqualAssemblies test relies on no deps.json -->
66
<GenerateDependencyFile>false</GenerateDependencyFile>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
8-
<NoWarn>$(NoWarn),SYSLIB0013</NoWarn>
8+
<!-- SYSLIB0013: Uri.EscapeUriString is obsolete
9+
SYSLIB0037: AssemblyName members HashAlgorithm, ProcessorArchitecture, and VersionCompatibility are obsolete. -->
10+
<NoWarn>$(NoWarn);SYSLIB0013;SYSLIB0037</NoWarn>
911

1012
<!-- these tests depend on the pdb files -->
1113
<DebuggerSupport Condition="'$(DebuggerSupport)' == '' and '$(TargetOS)' == 'Browser'">true</DebuggerSupport>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11363,12 +11363,15 @@ public AssemblyName(string assemblyName) { }
1136311363
public string? EscapedCodeBase { get { throw null; } }
1136411364
public System.Reflection.AssemblyNameFlags Flags { get { throw null; } set { } }
1136511365
public string FullName { get { throw null; } }
11366+
[System.ObsoleteAttribute("AssemblyName members HashAlgorithm, ProcessorArchitecture, and VersionCompatibility are obsolete and not supported.", DiagnosticId = "SYSLIB0037", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
1136611367
public System.Configuration.Assemblies.AssemblyHashAlgorithm HashAlgorithm { get { throw null; } set { } }
1136711368
[System.ObsoleteAttribute("Strong name signing is not supported and throws PlatformNotSupportedException.", DiagnosticId = "SYSLIB0017", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
1136811369
public System.Reflection.StrongNameKeyPair? KeyPair { get { throw null; } set { } }
1136911370
public string? Name { get { throw null; } set { } }
11371+
[System.ObsoleteAttribute("AssemblyName members HashAlgorithm, ProcessorArchitecture, and VersionCompatibility are obsolete and not supported.", DiagnosticId = "SYSLIB0037", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
1137011372
public System.Reflection.ProcessorArchitecture ProcessorArchitecture { get { throw null; } set { } }
1137111373
public System.Version? Version { get { throw null; } set { } }
11374+
[System.ObsoleteAttribute("AssemblyName members HashAlgorithm, ProcessorArchitecture, and VersionCompatibility are obsolete and not supported.", DiagnosticId = "SYSLIB0037", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
1137211375
public System.Configuration.Assemblies.AssemblyVersionCompatibility VersionCompatibility { get { throw null; } set { } }
1137311376
public object Clone() { throw null; }
1137411377
public static System.Reflection.AssemblyName GetAssemblyName(string assemblyFile) { throw null; }

0 commit comments

Comments
 (0)