Nullable: Enums, Structures from Reflection folder (#23933)
authorbuyaa-n <buyankhishig.namnan@microsoft.com>
Sat, 13 Apr 2019 00:00:35 +0000 (17:00 -0700)
committerGitHub <noreply@github.com>
Sat, 13 Apr 2019 00:00:35 +0000 (17:00 -0700)
* Nullable: Enums, Structures from Reflection

43 files changed:
src/System.Private.CoreLib/shared/System/Reflection/AssemblyContentType.cs
src/System.Private.CoreLib/shared/System/Reflection/AssemblyNameFlags.cs
src/System.Private.CoreLib/shared/System/Reflection/BindingFlags.cs
src/System.Private.CoreLib/shared/System/Reflection/CallingConventions.cs
src/System.Private.CoreLib/shared/System/Reflection/CorElementType.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/AssemblyBuilderAccess.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/EventToken.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/FieldToken.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/FlowControl.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/Label.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/MethodToken.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/OpCodeType.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/OpCodes.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/Opcode.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/OperandType.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/PEFileKinds.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/PackingSize.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/ParameterToken.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/PropertyToken.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/SignatureToken.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/StackBehaviour.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/StringToken.cs
src/System.Private.CoreLib/shared/System/Reflection/Emit/TypeToken.cs
src/System.Private.CoreLib/shared/System/Reflection/EventAttributes.cs
src/System.Private.CoreLib/shared/System/Reflection/ExceptionHandlingClause.cs
src/System.Private.CoreLib/shared/System/Reflection/ExceptionHandlingClauseOptions.cs
src/System.Private.CoreLib/shared/System/Reflection/FieldAttributes.cs
src/System.Private.CoreLib/shared/System/Reflection/GenericParameterAttributes.cs
src/System.Private.CoreLib/shared/System/Reflection/ImageFileMachine.cs
src/System.Private.CoreLib/shared/System/Reflection/InterfaceMapping.cs
src/System.Private.CoreLib/shared/System/Reflection/MemberTypes.cs
src/System.Private.CoreLib/shared/System/Reflection/MethodAttributes.cs
src/System.Private.CoreLib/shared/System/Reflection/MethodImplAttributes.cs
src/System.Private.CoreLib/shared/System/Reflection/ParameterAttributes.cs
src/System.Private.CoreLib/shared/System/Reflection/ParameterModifier.cs
src/System.Private.CoreLib/shared/System/Reflection/PortableExecutableKinds.cs
src/System.Private.CoreLib/shared/System/Reflection/ProcessorArchitecture.cs
src/System.Private.CoreLib/shared/System/Reflection/PropertyAttributes.cs
src/System.Private.CoreLib/shared/System/Reflection/ResourceAttributes.cs
src/System.Private.CoreLib/shared/System/Reflection/ResourceLocation.cs
src/System.Private.CoreLib/shared/System/Reflection/TypeAttributes.cs
src/System.Private.CoreLib/src/System/Reflection/INVOCATION_FLAGS.cs
src/System.Private.CoreLib/src/System/Reflection/RuntimeExceptionHandlingClause.cs

index 2ee1a00..938ac26 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection
 {
     public enum AssemblyContentType
index d321032..82f64c1 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection
 {
     [Flags]
index 7ba83e2..ac64814 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection
 {
     [Flags]
index bb6d6cd..3bd0607 100644 (file)
@@ -4,6 +4,7 @@
 
 // CallingConventions is a set of Bits representing the calling conventions in the system.
 
+#nullable enable
 namespace System.Reflection
 {
     [Flags]
index 37ffcfa..b6968f1 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection
 {
     internal enum CorElementType : byte
index b096960..baac3a7 100644 (file)
@@ -2,11 +2,10 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-using System;
-
 // This enumeration defines the access modes for a dynamic assembly.
 // EE uses these enum values..look for m_dwDynamicAssemblyAccess in Assembly.hpp
 
+#nullable enable
 namespace System.Reflection.Emit
 {
     [Flags]
index 7bcc9ac..85c9178 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection.Emit
 {
     public struct EventToken
@@ -17,7 +18,7 @@ namespace System.Reflection.Emit
 
         public override int GetHashCode() => Token;
 
-        public override bool Equals(object obj) => obj is EventToken et && Equals(et);
+        public override bool Equals(object? obj) => obj is EventToken et && Equals(et);
 
         public bool Equals(EventToken obj) => obj.Token == Token;
 
index 83af736..e0aba63 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection.Emit
 {
     /// <summary>
@@ -26,7 +27,7 @@ namespace System.Reflection.Emit
         
         public override int GetHashCode() => Token;
         
-        public override bool Equals(object obj) => obj is FieldToken ft && Equals(ft);
+        public override bool Equals(object? obj) => obj is FieldToken ft && Equals(ft);
 
         public bool Equals(FieldToken obj) => obj.Token == Token && obj._class == _class;
 
index 12a97c7..0410cc9 100644 (file)
@@ -12,8 +12,7 @@
 ** See $(RepoRoot)\src\inc\OpCodeGen.pl for more information.**
 ==============================================================*/
 
-using System;
-
+#nullable enable
 namespace System.Reflection.Emit
 {
     public enum FlowControl
index 503d8b3..4aa5e7c 100644 (file)
 ** 
 ===========================================================*/
 
-using System;
-using System.Reflection;
-using System.Runtime.InteropServices;
-
+#nullable enable
 namespace System.Reflection.Emit
 {
     // The Label class is an opaque representation of a label used by the 
@@ -49,7 +46,7 @@ namespace System.Reflection.Emit
             return m_label;
         }
 
-        public override bool Equals(object obj)
+        public override bool Equals(object? obj)
         {
             if (obj is Label)
                 return Equals((Label)obj);
index be4b0ee..0ed6872 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection.Emit
 {
     public struct MethodToken
@@ -17,7 +18,7 @@ namespace System.Reflection.Emit
 
         public override int GetHashCode() => Token;
 
-        public override bool Equals(object obj) => obj is MethodToken mt && Equals(mt);
+        public override bool Equals(object? obj) => obj is MethodToken mt && Equals(mt);
 
         public bool Equals(MethodToken obj) => obj.Token == Token;
 
index 4304c73..779aaca 100644 (file)
@@ -12,8 +12,7 @@
 ** See $(RepoRoot)\src\inc\OpCodeGen.pl for more information.**
 ==============================================================*/
 
-using System;
-
+#nullable enable
 namespace System.Reflection.Emit
 {
     public enum OpCodeType
index 7690005..b489593 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection.Emit
 {
     //
index fdac84f..6b191bf 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 using System.Threading;
 
 namespace System.Reflection.Emit
@@ -108,9 +109,9 @@ namespace System.Reflection.Emit
             }
         }
 
-        private static volatile string[] g_nameCache;
+        private static volatile string[]? g_nameCache;
 
-        public string Name
+        public string? Name
         {
             get
             {
@@ -119,7 +120,7 @@ namespace System.Reflection.Emit
 
                 // Create and cache the opcode names lazily. They should be rarely used (only for logging, etc.)
                 // Note that we do not any locks here because of we always get the same names. The last one wins.
-                string[] nameCache = g_nameCache;
+                string[]? nameCache = g_nameCache;
                 if (nameCache == null)
                 {
                     nameCache = new string[0x11f];
@@ -149,13 +150,13 @@ namespace System.Reflection.Emit
                     return name;
 
                 // Create ilasm style name from the enum value name.
-                name = Enum.GetName(typeof(OpCodeValues), opCodeValue).ToLowerInvariant().Replace('_', '.');
+                name = Enum.GetName(typeof(OpCodeValues), opCodeValue)!.ToLowerInvariant().Replace('_', '.');
                 Volatile.Write(ref nameCache[idx], name);
                 return name;
             }
         }
 
-        public override bool Equals(object obj)
+        public override bool Equals(object? obj)
         {
             if (obj is OpCode)
                 return Equals((OpCode)obj);
@@ -183,7 +184,7 @@ namespace System.Reflection.Emit
             return Value;
         }
 
-        public override string ToString()
+        public override string? ToString()
         {
             return Name;
         }
index 356fffa..3bc5c70 100644 (file)
@@ -12,8 +12,7 @@
 ** See $(RepoRoot)\src\inc\OpCodeGen.pl for more information.**
 ==============================================================*/
 
-using System;
-
+#nullable enable
 namespace System.Reflection.Emit
 {
     public enum OperandType
index f6606c4..d01e6bf 100644 (file)
@@ -2,9 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-
-using System;
-
+#nullable enable
 namespace System.Reflection.Emit
 {
     // This Enum matchs the CorFieldAttr defined in CorHdr.h
index f734e1a..d0bb044 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection.Emit
 {
     public enum PackingSize
index d8a087d..a0ce2ee 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection.Emit
 {  
     /// <summary>
@@ -21,7 +22,7 @@ namespace System.Reflection.Emit
 
         public override int GetHashCode() => Token;
 
-        public override bool Equals(object obj) => obj is ParameterToken pt && Equals(pt);
+        public override bool Equals(object? obj) => obj is ParameterToken pt && Equals(pt);
 
         public bool Equals(ParameterToken obj) => obj.Token == Token;
 
index b63fe78..c116426 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection.Emit
 {
     public struct PropertyToken
@@ -17,7 +18,7 @@ namespace System.Reflection.Emit
 
         public override int GetHashCode() => Token;
 
-        public override bool Equals(object obj) => obj is PropertyToken pt && Equals(pt);
+        public override bool Equals(object? obj) => obj is PropertyToken pt && Equals(pt);
 
         public bool Equals(PropertyToken obj) => obj.Token == Token;
 
index ba58358..5af7ca2 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection.Emit
 {
     public struct SignatureToken
@@ -17,7 +18,7 @@ namespace System.Reflection.Emit
 
         public override int GetHashCode() => Token;
 
-        public override bool Equals(object obj) => obj is SignatureToken st && Equals(st);
+        public override bool Equals(object? obj) => obj is SignatureToken st && Equals(st);
 
         public bool Equals(SignatureToken obj) => obj.Token == Token;
 
index 3e64b48..6015da5 100644 (file)
@@ -12,8 +12,7 @@
 ** See $(RepoRoot)\src\inc\OpCodeGen.pl for more information.**
 ==============================================================*/
 
-using System;
-
+#nullable enable
 namespace System.Reflection.Emit
 {
     public enum StackBehaviour
index 380f0ab..02d3a87 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection.Emit
 {
     public struct StringToken
@@ -18,7 +19,7 @@ namespace System.Reflection.Emit
 
         public override int GetHashCode() => Token;
 
-        public override bool Equals(object obj) => obj is StringToken st && Equals(st);
+        public override bool Equals(object? obj) => obj is StringToken st && Equals(st);
 
         public bool Equals(StringToken obj) => obj.Token == Token;
 
index da8a5da..303716b 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection.Emit
 {
     public struct TypeToken
@@ -17,7 +18,7 @@ namespace System.Reflection.Emit
 
         public override int GetHashCode() => Token;
 
-        public override bool Equals(object obj) => obj is TypeToken tt && Equals(tt);
+        public override bool Equals(object? obj) => obj is TypeToken tt && Equals(tt);
 
         public bool Equals(TypeToken obj) => obj.Token == Token;
 
index fbc2972..b41e84e 100644 (file)
@@ -5,6 +5,7 @@
 // EventAttributes are an enum defining the attributes associated with and Event.
 // These are defined in CorHdr.h and are a combination of bits and enums.
 
+#nullable enable
 namespace System.Reflection
 {
     [Flags]
index 15780f1..5e753fd 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 using System.Globalization;
 
 namespace System.Reflection
@@ -15,7 +16,7 @@ namespace System.Reflection
         public virtual int HandlerOffset => 0;
         public virtual int HandlerLength => 0;
         public virtual int FilterOffset => throw new InvalidOperationException(SR.Arg_EHClauseNotFilter);
-        public virtual Type CatchType => null;
+        public virtual Type? CatchType => null;
 
         public override string ToString()
         {
index 46285f7..30c72e5 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection
 {
     [Flags]
index 048d0e7..90cc482 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection
 {
     // This Enum matchs the CorFieldAttr defined in CorHdr.h
index 4b579d2..4cf14a5 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection
 {
     [Flags]
index 230bc95..425967a 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection
 {
     public enum ImageFileMachine
index 2e0c0d8..ec8b118 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable // TODO-NULLABLE: Re-review
 namespace System.Reflection
 {
     public struct InterfaceMapping
index 57072dc..06823b8 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection
 {
     [Flags]
@@ -17,4 +18,4 @@ namespace System.Reflection
         NestedType = 0x80,
         All = Constructor | Event | Field | Method | Property | TypeInfo | NestedType,
     }
-}
\ No newline at end of file
+}
index 1a7c7bf..4448eb5 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection
 {
     [Flags]
index b16f4a4..f46331b 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection
 {
     // This Enum matchs the CorMethodImpl defined in CorHdr.h
index ce19589..12cd1f4 100644 (file)
@@ -5,6 +5,7 @@
 // ParameterAttributes is an enum defining the attributes that may be 
 // associated with a Parameter.  These are defined in CorHdr.h.
 
+#nullable enable
 namespace System.Reflection
 {
     // This Enum matchs the CorParamAttr defined in CorHdr.h
index 0fb75ff..1b9cc08 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection
 {
     public readonly struct ParameterModifier
index 79be338..b6427fd 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection
 {
     [Flags]
index becb346..a907521 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection
 {
     public enum ProcessorArchitecture
index 31e7a65..1722fb4 100644 (file)
@@ -5,6 +5,7 @@
 // PropertyAttributes is an enum which defines the attributes that may be associated
 // with a property.  The values here are defined in Corhdr.h.
 
+#nullable enable
 namespace System.Reflection
 {
     // This Enum matchs the CorPropertyAttr defined in CorHdr.h
index 2d03f42..26f5e75 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection
 {
     [Flags]
index 4902333..12d8928 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection
 {
     [Flags]
index aa30331..e164a29 100644 (file)
@@ -2,8 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-using System.Runtime.InteropServices;
-
+#nullable enable
 namespace System.Reflection
 {
     // This Enum matchs the CorTypeAttr defined in CorHdr.h
index eb28f4e..2cd9c96 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 namespace System.Reflection
 {
     //
index eff671e..4d88f48 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#nullable enable
 using System.Globalization;
 
 namespace System.Reflection
@@ -11,7 +12,7 @@ namespace System.Reflection
         // This class can only be created from inside the EE.
         private RuntimeExceptionHandlingClause() { }
         
-        private RuntimeMethodBody _methodBody;
+        private RuntimeMethodBody _methodBody = null!;
         private ExceptionHandlingClauseOptions _flags;
         private int _tryOffset;
         private int _tryLength;
@@ -37,14 +38,14 @@ namespace System.Reflection
             }
         }
 
-        public override Type CatchType
+        public override Type? CatchType
         {
             get
             {
                 if (_flags != ExceptionHandlingClauseOptions.Clause)
                     throw new InvalidOperationException(SR.Arg_EHClauseNotClause);
 
-                Type type = null;
+                Type? type = null;
 
                 if (!MetadataToken.IsNullToken(_catchMetadataToken))
                 {