Skip to content

Commit

Permalink
Apply feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
buyaa-n committed Apr 22, 2021
1 parent edd5059 commit e20427e
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 19 deletions.
3 changes: 2 additions & 1 deletion docs/project/list-of-diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Currently the identifiers `SYSLIB0001` through `SYSLIB0999` are carved out for o
| __`SYSLIB0013`__ | Uri.EscapeUriString can corrupt the Uri string in some cases. Consider using Uri.EscapeDataString for query string components instead. |
| __`SYSLIB0015`__ | DisablePrivateReflectionAttribute has no effect in .NET 6.0+ applications. |
| __`SYSLIB0016`__ | Use the Graphics.GetContextInfo overloads that accept arguments for better performance and fewer allocations. |
| __`SYSLIB0017`__ | Strong name signing is not supported on this platform.|
| __`SYSLIB0017`__ | Strong name signing is not supported and throws PlatformNotSupportedException. |
| __`SYSLIB0018`__ | ReflectionOnly loading is not supported and throws PlatformNotSupportedException. |

### Analyzer warnings (`SYSLIB1001` - `SYSLIB1999`)
| Diagnostic ID | Description |
Expand Down
5 changes: 4 additions & 1 deletion src/libraries/Common/src/System/Obsoletions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ internal static class Obsoletions
internal const string GetContextInfoMessage = "Use the Graphics.GetContextInfo overloads that accept arguments for better performance and fewer allocations.";
internal const string GetContextInfoDiagId = "SYSLIB0016";

internal const string StrongNameKeyPairMessage = "Strong name signing is not supported on this platform.";
internal const string StrongNameKeyPairMessage = "Strong name signing is not supported and throws PlatformNotSupportedException.";
internal const string StrongNameKeyPairDiagId = "SYSLIB0017";

internal const string ReflectionOnlyLoadingMessage = "ReflectionOnly loading is not supported and throws PlatformNotSupportedException.";
internal const string ReflectionOnlyLoadingDiagId = "SYSLIB0018";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,13 @@ public static Assembly LoadFrom(string assemblyFile, byte[]? hashValue, Assembly
[RequiresUnreferencedCode("Types and members the loaded module depends on might be removed")]
public virtual Module LoadModule(string moduleName, byte[]? rawModule, byte[]? rawSymbolStore) { throw NotImplemented.ByDesign; }

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public AssemblyVersionCompatibility VersionCompatibility
set => _versionCompatibility = value;
}

[Obsolete(Obsoletions.StrongNameKeyPairMessage, DiagnosticId = Obsoletions.StrongNameKeyPairDiagId)]
[Obsolete(Obsoletions.StrongNameKeyPairMessage, DiagnosticId = Obsoletions.StrongNameKeyPairDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public StrongNameKeyPair? KeyPair
{
get => throw new PlatformNotSupportedException(SR.PlatformNotSupported_StrongNameSigning);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace System.Reflection
{
[Obsolete(Obsoletions.StrongNameKeyPairMessage, DiagnosticId = Obsoletions.StrongNameKeyPairDiagId)]
[Obsolete(Obsoletions.StrongNameKeyPairMessage, DiagnosticId = Obsoletions.StrongNameKeyPairDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public class StrongNameKeyPair : IDeserializationCallback, ISerializable
{
public StrongNameKeyPair(FileStream keyPairFile) =>
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Private.CoreLib/src/System/Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ public override int GetHashCode()
}
public virtual bool Equals(Type? o) => o == null ? false : object.ReferenceEquals(this.UnderlyingSystemType, o.UnderlyingSystemType);

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

public static Binder DefaultBinder
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/System.Reflection/tests/AssemblyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ public void AssemblyLoadFromBytesWithSymbols()
Assert.Equal(assembly.FullName, loadedAssembly.FullName);
}

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

public static IEnumerable<object[]> GetModules_TestData()
{
Expand Down
12 changes: 6 additions & 6 deletions src/libraries/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4571,7 +4571,7 @@ protected Type() { }
public virtual System.Type MakePointerType() { throw null; }
public static bool operator ==(System.Type? left, System.Type? right) { throw null; }
public static bool operator !=(System.Type? left, System.Type? right) { throw null; }
[System.ObsoleteAttribute("ReflectionOnly loading is not supported on this platform.")]
[System.ObsoleteAttribute("ReflectionOnly loading is not supported and throws PlatformNotSupportedException.", DiagnosticId = "SYSLIB0018", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public static System.Type? ReflectionOnlyGetType(string typeName, bool throwIfNotFound, bool ignoreCase) { throw null; }
public override string ToString() { throw null; }
}
Expand Down Expand Up @@ -7945,13 +7945,13 @@ public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo
public static System.Reflection.Assembly? LoadWithPartialName(string partialName) { throw null; }
public static bool operator ==(System.Reflection.Assembly? left, System.Reflection.Assembly? right) { throw null; }
public static bool operator !=(System.Reflection.Assembly? left, System.Reflection.Assembly? right) { throw null; }
[System.ObsoleteAttribute("ReflectionOnly loading is not supported on this platform.")]
[System.ObsoleteAttribute("ReflectionOnly loading is not supported and throws PlatformNotSupportedException.", DiagnosticId = "SYSLIB0018", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Types and members the loaded assembly depends on might be removed")]
public static System.Reflection.Assembly ReflectionOnlyLoad(byte[] rawAssembly) { throw null; }
[System.ObsoleteAttribute("ReflectionOnly loading is not supported on this platform.")]
[System.ObsoleteAttribute("ReflectionOnly loading is not supported and throws PlatformNotSupportedException.", DiagnosticId = "SYSLIB0018", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Types and members the loaded assembly depends on might be removed")]
public static System.Reflection.Assembly ReflectionOnlyLoad(string assemblyString) { throw null; }
[System.ObsoleteAttribute("ReflectionOnly loading is not supported on this platform.")]
[System.ObsoleteAttribute("ReflectionOnly loading is not supported and throws PlatformNotSupportedException.", DiagnosticId = "SYSLIB0018", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Types and members the loaded assembly depends on might be removed")]
public static System.Reflection.Assembly ReflectionOnlyLoadFrom(string assemblyFile) { throw null; }
public override string ToString() { throw null; }
Expand Down Expand Up @@ -8071,7 +8071,7 @@ public AssemblyName(string assemblyName) { }
public System.Reflection.AssemblyNameFlags Flags { get { throw null; } set { } }
public string FullName { get { throw null; } }
public System.Configuration.Assemblies.AssemblyHashAlgorithm HashAlgorithm { get { throw null; } set { } }
[System.ObsoleteAttribute("Strong name signing is not supported on this platform.", DiagnosticId = "SYSLIB0017")]
[System.ObsoleteAttribute("Strong name signing is not supported and throws PlatformNotSupportedException.", DiagnosticId = "SYSLIB0017", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public System.Reflection.StrongNameKeyPair? KeyPair { get { throw null; } set { } }
public string? Name { get { throw null; } set { } }
public System.Reflection.ProcessorArchitecture ProcessorArchitecture { get { throw null; } set { } }
Expand Down Expand Up @@ -8919,7 +8919,7 @@ public static partial class RuntimeReflectionExtensions
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; }
public static System.Reflection.PropertyInfo? GetRuntimeProperty([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] this System.Type type, string name) { throw null; }
}
[System.ObsoleteAttribute("Strong name signing is not supported on this platform.", DiagnosticId = "SYSLIB0017")]
[System.ObsoleteAttribute("Strong name signing is not supported and throws PlatformNotSupportedException.", DiagnosticId = "SYSLIB0017", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public partial class StrongNameKeyPair : System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
{
public StrongNameKeyPair(byte[] keyPairArray) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace System.Reflection.Tests
{
public class StrongNameKeyPairTests : FileCleanupTestBase
{
#pragma warning disable SYSLIB0017 // Strong name signing is not supported on this platform.
#pragma warning disable SYSLIB0017 // Strong name signing is not supported and throws PlatformNotSupportedException.
[Fact]
public void Ctor_ByteArray_ThrowsPlatformNotSupportedException()
{
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/System.Runtime/tests/System/Type/TypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,11 @@ public void GetTypeCode_ValidType_ReturnsExpected(Type t, TypeCode typeCode)
[Fact]
public void ReflectionOnlyGetType()
{
#pragma warning disable CS0618 // ReflectionOnly loading is not supported on this platform.
#pragma warning disable SYSLIB0018 // ReflectionOnly loading is not supported and throws PlatformNotSupportedException.
Assert.Throws<PlatformNotSupportedException>(() => Type.ReflectionOnlyGetType(null, true, false));
Assert.Throws<PlatformNotSupportedException>(() => Type.ReflectionOnlyGetType("", true, true));
Assert.Throws<PlatformNotSupportedException>(() => Type.ReflectionOnlyGetType("System.Tests.TypeTests", false, true));
#pragma warning restore CS0618
#pragma warning restore SYSLIB0018
}

[Fact]
Expand Down

0 comments on commit e20427e

Please sign in to comment.