Skip to content

Commit e20427e

Browse files
committed
Apply feedbacks
1 parent edd5059 commit e20427e

File tree

10 files changed

+23
-19
lines changed

10 files changed

+23
-19
lines changed

docs/project/list-of-diagnostics.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ Currently the identifiers `SYSLIB0001` through `SYSLIB0999` are carved out for o
2828
| __`SYSLIB0013`__ | Uri.EscapeUriString can corrupt the Uri string in some cases. Consider using Uri.EscapeDataString for query string components instead. |
2929
| __`SYSLIB0015`__ | DisablePrivateReflectionAttribute has no effect in .NET 6.0+ applications. |
3030
| __`SYSLIB0016`__ | Use the Graphics.GetContextInfo overloads that accept arguments for better performance and fewer allocations. |
31-
| __`SYSLIB0017`__ | Strong name signing is not supported on this platform.|
31+
| __`SYSLIB0017`__ | Strong name signing is not supported and throws PlatformNotSupportedException. |
32+
| __`SYSLIB0018`__ | ReflectionOnly loading is not supported and throws PlatformNotSupportedException. |
3233

3334
### Analyzer warnings (`SYSLIB1001` - `SYSLIB1999`)
3435
| Diagnostic ID | Description |

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ internal static class Obsoletions
5555
internal const string GetContextInfoMessage = "Use the Graphics.GetContextInfo overloads that accept arguments for better performance and fewer allocations.";
5656
internal const string GetContextInfoDiagId = "SYSLIB0016";
5757

58-
internal const string StrongNameKeyPairMessage = "Strong name signing is not supported on this platform.";
58+
internal const string StrongNameKeyPairMessage = "Strong name signing is not supported and throws PlatformNotSupportedException.";
5959
internal const string StrongNameKeyPairDiagId = "SYSLIB0017";
60+
61+
internal const string ReflectionOnlyLoadingMessage = "ReflectionOnly loading is not supported and throws PlatformNotSupportedException.";
62+
internal const string ReflectionOnlyLoadingDiagId = "SYSLIB0018";
6063
}
6164
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,13 +372,13 @@ public static Assembly LoadFrom(string assemblyFile, byte[]? hashValue, Assembly
372372
[RequiresUnreferencedCode("Types and members the loaded module depends on might be removed")]
373373
public virtual Module LoadModule(string moduleName, byte[]? rawModule, byte[]? rawSymbolStore) { throw NotImplemented.ByDesign; }
374374

375-
[Obsolete("ReflectionOnly loading is not supported on this platform.")]
375+
[Obsolete(Obsoletions.ReflectionOnlyLoadingMessage, DiagnosticId = Obsoletions.ReflectionOnlyLoadingDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
376376
[RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")]
377377
public static Assembly ReflectionOnlyLoad(byte[] rawAssembly) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ReflectionOnly); }
378-
[Obsolete("ReflectionOnly loading is not supported on this platform.")]
378+
[Obsolete(Obsoletions.ReflectionOnlyLoadingMessage, DiagnosticId = Obsoletions.ReflectionOnlyLoadingDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
379379
[RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")]
380380
public static Assembly ReflectionOnlyLoad(string assemblyString) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ReflectionOnly); }
381-
[Obsolete("ReflectionOnly loading is not supported on this platform.")]
381+
[Obsolete(Obsoletions.ReflectionOnlyLoadingMessage, DiagnosticId = Obsoletions.ReflectionOnlyLoadingDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
382382
[RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")]
383383
public static Assembly ReflectionOnlyLoadFrom(string assemblyFile) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ReflectionOnly); }
384384

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public AssemblyVersionCompatibility VersionCompatibility
198198
set => _versionCompatibility = value;
199199
}
200200

201-
[Obsolete(Obsoletions.StrongNameKeyPairMessage, DiagnosticId = Obsoletions.StrongNameKeyPairDiagId)]
201+
[Obsolete(Obsoletions.StrongNameKeyPairMessage, DiagnosticId = Obsoletions.StrongNameKeyPairDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
202202
public StrongNameKeyPair? KeyPair
203203
{
204204
get => throw new PlatformNotSupportedException(SR.PlatformNotSupported_StrongNameSigning);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace System.Reflection
88
{
9-
[Obsolete(Obsoletions.StrongNameKeyPairMessage, DiagnosticId = Obsoletions.StrongNameKeyPairDiagId)]
9+
[Obsolete(Obsoletions.StrongNameKeyPairMessage, DiagnosticId = Obsoletions.StrongNameKeyPairDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
1010
public class StrongNameKeyPair : IDeserializationCallback, ISerializable
1111
{
1212
public StrongNameKeyPair(FileStream keyPairFile) =>

src/libraries/System.Private.CoreLib/src/System/Type.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ public override int GetHashCode()
541541
}
542542
public virtual bool Equals(Type? o) => o == null ? false : object.ReferenceEquals(this.UnderlyingSystemType, o.UnderlyingSystemType);
543543

544-
[Obsolete("ReflectionOnly loading is not supported on this platform.")]
544+
[Obsolete(Obsoletions.ReflectionOnlyLoadingMessage, DiagnosticId = Obsoletions.ReflectionOnlyLoadingDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
545545
public static Type? ReflectionOnlyGetType(string typeName, bool throwIfNotFound, bool ignoreCase) => throw new PlatformNotSupportedException(SR.PlatformNotSupported_ReflectionOnly);
546546

547547
public static Binder DefaultBinder

src/libraries/System.Reflection/tests/AssemblyTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ public void AssemblyLoadFromBytesWithSymbols()
728728
Assert.Equal(assembly.FullName, loadedAssembly.FullName);
729729
}
730730

731-
#pragma warning disable CS0618 // ReflectionOnly loading is not supported on this platform.
731+
#pragma warning disable SYSLIB0018 // ReflectionOnly loading is not supported and throws PlatformNotSupportedException.
732732
[Fact]
733733
public void AssemblyReflectionOnlyLoadFromString()
734734
{
@@ -751,7 +751,7 @@ public void AssemblyReflectionOnlyLoadFromNeg()
751751
Assert.Throws<PlatformNotSupportedException>(() => Assembly.ReflectionOnlyLoad(string.Empty));
752752
Assert.Throws<PlatformNotSupportedException>(() => Assembly.ReflectionOnlyLoad((byte[])null));
753753
}
754-
#pragma warning restore CS0618
754+
#pragma warning restore SYSLIB0018
755755

756756
public static IEnumerable<object[]> GetModules_TestData()
757757
{

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4571,7 +4571,7 @@ protected Type() { }
45714571
public virtual System.Type MakePointerType() { throw null; }
45724572
public static bool operator ==(System.Type? left, System.Type? right) { throw null; }
45734573
public static bool operator !=(System.Type? left, System.Type? right) { throw null; }
4574-
[System.ObsoleteAttribute("ReflectionOnly loading is not supported on this platform.")]
4574+
[System.ObsoleteAttribute("ReflectionOnly loading is not supported and throws PlatformNotSupportedException.", DiagnosticId = "SYSLIB0018", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
45754575
public static System.Type? ReflectionOnlyGetType(string typeName, bool throwIfNotFound, bool ignoreCase) { throw null; }
45764576
public override string ToString() { throw null; }
45774577
}
@@ -7945,13 +7945,13 @@ public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo
79457945
public static System.Reflection.Assembly? LoadWithPartialName(string partialName) { throw null; }
79467946
public static bool operator ==(System.Reflection.Assembly? left, System.Reflection.Assembly? right) { throw null; }
79477947
public static bool operator !=(System.Reflection.Assembly? left, System.Reflection.Assembly? right) { throw null; }
7948-
[System.ObsoleteAttribute("ReflectionOnly loading is not supported on this platform.")]
7948+
[System.ObsoleteAttribute("ReflectionOnly loading is not supported and throws PlatformNotSupportedException.", DiagnosticId = "SYSLIB0018", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
79497949
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Types and members the loaded assembly depends on might be removed")]
79507950
public static System.Reflection.Assembly ReflectionOnlyLoad(byte[] rawAssembly) { throw null; }
7951-
[System.ObsoleteAttribute("ReflectionOnly loading is not supported on this platform.")]
7951+
[System.ObsoleteAttribute("ReflectionOnly loading is not supported and throws PlatformNotSupportedException.", DiagnosticId = "SYSLIB0018", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
79527952
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Types and members the loaded assembly depends on might be removed")]
79537953
public static System.Reflection.Assembly ReflectionOnlyLoad(string assemblyString) { throw null; }
7954-
[System.ObsoleteAttribute("ReflectionOnly loading is not supported on this platform.")]
7954+
[System.ObsoleteAttribute("ReflectionOnly loading is not supported and throws PlatformNotSupportedException.", DiagnosticId = "SYSLIB0018", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
79557955
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Types and members the loaded assembly depends on might be removed")]
79567956
public static System.Reflection.Assembly ReflectionOnlyLoadFrom(string assemblyFile) { throw null; }
79577957
public override string ToString() { throw null; }
@@ -8071,7 +8071,7 @@ public AssemblyName(string assemblyName) { }
80718071
public System.Reflection.AssemblyNameFlags Flags { get { throw null; } set { } }
80728072
public string FullName { get { throw null; } }
80738073
public System.Configuration.Assemblies.AssemblyHashAlgorithm HashAlgorithm { get { throw null; } set { } }
8074-
[System.ObsoleteAttribute("Strong name signing is not supported on this platform.", DiagnosticId = "SYSLIB0017")]
8074+
[System.ObsoleteAttribute("Strong name signing is not supported and throws PlatformNotSupportedException.", DiagnosticId = "SYSLIB0017", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
80758075
public System.Reflection.StrongNameKeyPair? KeyPair { get { throw null; } set { } }
80768076
public string? Name { get { throw null; } set { } }
80778077
public System.Reflection.ProcessorArchitecture ProcessorArchitecture { get { throw null; } set { } }
@@ -8919,7 +8919,7 @@ public static partial class RuntimeReflectionExtensions
89198919
public static System.Collections.Generic.IEnumerable<System.Reflection.PropertyInfo> GetRuntimeProperties([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] this System.Type type) { throw null; }
89208920
public static System.Reflection.PropertyInfo? GetRuntimeProperty([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] this System.Type type, string name) { throw null; }
89218921
}
8922-
[System.ObsoleteAttribute("Strong name signing is not supported on this platform.", DiagnosticId = "SYSLIB0017")]
8922+
[System.ObsoleteAttribute("Strong name signing is not supported and throws PlatformNotSupportedException.", DiagnosticId = "SYSLIB0017", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
89238923
public partial class StrongNameKeyPair : System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
89248924
{
89258925
public StrongNameKeyPair(byte[] keyPairArray) { }

src/libraries/System.Runtime/tests/System/Reflection/StrongNameKeyPairTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace System.Reflection.Tests
1111
{
1212
public class StrongNameKeyPairTests : FileCleanupTestBase
1313
{
14-
#pragma warning disable SYSLIB0017 // Strong name signing is not supported on this platform.
14+
#pragma warning disable SYSLIB0017 // Strong name signing is not supported and throws PlatformNotSupportedException.
1515
[Fact]
1616
public void Ctor_ByteArray_ThrowsPlatformNotSupportedException()
1717
{

src/libraries/System.Runtime/tests/System/Type/TypeTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,11 +570,11 @@ public void GetTypeCode_ValidType_ReturnsExpected(Type t, TypeCode typeCode)
570570
[Fact]
571571
public void ReflectionOnlyGetType()
572572
{
573-
#pragma warning disable CS0618 // ReflectionOnly loading is not supported on this platform.
573+
#pragma warning disable SYSLIB0018 // ReflectionOnly loading is not supported and throws PlatformNotSupportedException.
574574
Assert.Throws<PlatformNotSupportedException>(() => Type.ReflectionOnlyGetType(null, true, false));
575575
Assert.Throws<PlatformNotSupportedException>(() => Type.ReflectionOnlyGetType("", true, true));
576576
Assert.Throws<PlatformNotSupportedException>(() => Type.ReflectionOnlyGetType("System.Tests.TypeTests", false, true));
577-
#pragma warning restore CS0618
577+
#pragma warning restore SYSLIB0018
578578
}
579579

580580
[Fact]

0 commit comments

Comments
 (0)