summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStephen Toub <stoub@microsoft.com>2019-05-10 09:18:53 -0400
committerGitHub <noreply@github.com>2019-05-10 09:18:53 -0400
commit5e35e287fbdf4c8b3eef83df39fa0e1897a33f06 (patch)
tree7b9d9c4cced413fd1d923d72ffd75fcdf6d6ca2c /src
parent48431cc037776ca359de36bf71bda8c154cc2aa9 (diff)
downloadcoreclr-5e35e287fbdf4c8b3eef83df39fa0e1897a33f06.tar.gz
coreclr-5e35e287fbdf4c8b3eef83df39fa0e1897a33f06.tar.bz2
coreclr-5e35e287fbdf4c8b3eef83df39fa0e1897a33f06.zip
Tweak a few nullable annotations (#24494)
- Assembly.ToString() won't return null - Several attributes have the intent that their arguments are non-nullable, even though they don't check and throw; the annotations should match the intent in such cases.
Diffstat (limited to 'src')
-rw-r--r--src/System.Private.CoreLib/shared/System/Diagnostics/CodeAnalysis/SuppressMessageAttribute.cs6
-rw-r--r--src/System.Private.CoreLib/shared/System/Diagnostics/DebuggerTypeProxyAttribute.cs6
-rw-r--r--src/System.Private.CoreLib/shared/System/Diagnostics/DebuggerVisualizerAttribute.cs14
-rw-r--r--src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs8
4 files changed, 15 insertions, 19 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/CodeAnalysis/SuppressMessageAttribute.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/CodeAnalysis/SuppressMessageAttribute.cs
index 28208a379e..8ed44b0e65 100644
--- a/src/System.Private.CoreLib/shared/System/Diagnostics/CodeAnalysis/SuppressMessageAttribute.cs
+++ b/src/System.Private.CoreLib/shared/System/Diagnostics/CodeAnalysis/SuppressMessageAttribute.cs
@@ -23,14 +23,14 @@ namespace System.Diagnostics.CodeAnalysis
[Conditional("CODE_ANALYSIS")]
public sealed class SuppressMessageAttribute : Attribute
{
- public SuppressMessageAttribute(string? category, string? checkId)
+ public SuppressMessageAttribute(string category, string checkId)
{
Category = category;
CheckId = checkId;
}
- public string? Category { get; }
- public string? CheckId { get; }
+ public string Category { get; }
+ public string CheckId { get; }
public string? Scope { get; set; }
public string? Target { get; set; }
public string? MessageId { get; set; }
diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/DebuggerTypeProxyAttribute.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/DebuggerTypeProxyAttribute.cs
index 5acc0185b0..375a7f4011 100644
--- a/src/System.Private.CoreLib/shared/System/Diagnostics/DebuggerTypeProxyAttribute.cs
+++ b/src/System.Private.CoreLib/shared/System/Diagnostics/DebuggerTypeProxyAttribute.cs
@@ -16,15 +16,15 @@ namespace System.Diagnostics
throw new ArgumentNullException(nameof(type));
}
- ProxyTypeName = type.AssemblyQualifiedName;
+ ProxyTypeName = type.AssemblyQualifiedName!;
}
- public DebuggerTypeProxyAttribute(string? typeName)
+ public DebuggerTypeProxyAttribute(string typeName)
{
ProxyTypeName = typeName;
}
- public string? ProxyTypeName { get; }
+ public string ProxyTypeName { get; }
public Type? Target
{
diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/DebuggerVisualizerAttribute.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/DebuggerVisualizerAttribute.cs
index b7f9e16c06..48f81203f1 100644
--- a/src/System.Private.CoreLib/shared/System/Diagnostics/DebuggerVisualizerAttribute.cs
+++ b/src/System.Private.CoreLib/shared/System/Diagnostics/DebuggerVisualizerAttribute.cs
@@ -13,18 +13,18 @@ namespace System.Diagnostics
{
private Type? _target;
- public DebuggerVisualizerAttribute(string? visualizerTypeName)
+ public DebuggerVisualizerAttribute(string visualizerTypeName)
{
VisualizerTypeName = visualizerTypeName;
}
- public DebuggerVisualizerAttribute(string? visualizerTypeName, string? visualizerObjectSourceTypeName)
+ public DebuggerVisualizerAttribute(string visualizerTypeName, string? visualizerObjectSourceTypeName)
{
VisualizerTypeName = visualizerTypeName;
VisualizerObjectSourceTypeName = visualizerObjectSourceTypeName;
}
- public DebuggerVisualizerAttribute(string? visualizerTypeName, Type visualizerObjectSource)
+ public DebuggerVisualizerAttribute(string visualizerTypeName, Type visualizerObjectSource)
{
if (visualizerObjectSource == null)
{
@@ -42,7 +42,7 @@ namespace System.Diagnostics
throw new ArgumentNullException(nameof(visualizer));
}
- VisualizerTypeName = visualizer.AssemblyQualifiedName;
+ VisualizerTypeName = visualizer.AssemblyQualifiedName!;
}
public DebuggerVisualizerAttribute(Type visualizer, Type visualizerObjectSource)
@@ -56,7 +56,7 @@ namespace System.Diagnostics
throw new ArgumentNullException(nameof(visualizerObjectSource));
}
- VisualizerTypeName = visualizer.AssemblyQualifiedName;
+ VisualizerTypeName = visualizer.AssemblyQualifiedName!;
VisualizerObjectSourceTypeName = visualizerObjectSource.AssemblyQualifiedName;
}
@@ -67,13 +67,13 @@ namespace System.Diagnostics
throw new ArgumentNullException(nameof(visualizer));
}
- VisualizerTypeName = visualizer.AssemblyQualifiedName;
+ VisualizerTypeName = visualizer.AssemblyQualifiedName!;
VisualizerObjectSourceTypeName = visualizerObjectSourceTypeName;
}
public string? VisualizerObjectSourceTypeName { get; }
- public string? VisualizerTypeName { get; }
+ public string VisualizerTypeName { get; }
public string? Description { get; set; }
diff --git a/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs b/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs
index ecae2893b3..78ab61b4a3 100644
--- a/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs
+++ b/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs
@@ -140,13 +140,9 @@ namespace System.Reflection
public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { throw NotImplemented.ByDesign; }
- public override string? ToString()
+ public override string ToString()
{
- string? displayName = FullName;
- if (displayName == null)
- return base.ToString();
- else
- return displayName;
+ return FullName ?? base.ToString()!;
}
/*