More PR Feedback
authorSantiago Fernandez Madero <safern@microsoft.com>
Tue, 4 Jun 2019 22:26:31 +0000 (15:26 -0700)
committerSantiago Fernandez Madero <safern@microsoft.com>
Tue, 4 Jun 2019 22:27:26 +0000 (15:27 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/b9e65b9ae77fa06a51d6e51ee92426beddd61e58

src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/EmptyCAHolder.cs [new file with mode: 0644]
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolMethod.cs
src/libraries/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs

index b3646fc..fa59f80 100644 (file)
     <Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\CustomAttributeBuilder.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\DynamicILGenerator.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\DynamicMethod.cs" />
+    <Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\EmptyCAHolder.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\EnumBuilder.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\EventBuilder.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\FieldBuilder.cs" />
index 9901d9c..c012744 100644 (file)
@@ -719,14 +719,7 @@ namespace System.Reflection.Emit
                 get { return new RuntimeParameterInfo(this, null, m_owner.m_returnType, -1); }
             }
 
-            public override ICustomAttributeProvider ReturnTypeCustomAttributes
-            {
-                get { return GetEmptyCAHolder(); }
-            }
-
-            //
-            // private implementation
-            //
+            public override ICustomAttributeProvider ReturnTypeCustomAttributes => new EmptyCAHolder();
 
             internal RuntimeParameterInfo[] LoadParameters()
             {
@@ -742,34 +735,6 @@ namespace System.Reflection.Emit
                 }
                 return m_parameters;
             }
-
-            // private implementation of CA for the return type
-            private ICustomAttributeProvider GetEmptyCAHolder()
-            {
-                return new EmptyCAHolder();
-            }
-
-            ///////////////////////////////////////////////////
-            // EmptyCAHolder
-            private class EmptyCAHolder : ICustomAttributeProvider
-            {
-                internal EmptyCAHolder() { }
-
-                object[] ICustomAttributeProvider.GetCustomAttributes(Type attributeType, bool inherit)
-                {
-                    return Array.Empty<object>();
-                }
-
-                object[] ICustomAttributeProvider.GetCustomAttributes(bool inherit)
-                {
-                    return Array.Empty<object>();
-                }
-
-                bool ICustomAttributeProvider.IsDefined(Type attributeType, bool inherit)
-                {
-                    return false;
-                }
-            }
         }
     }
 }
diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/EmptyCAHolder.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/EmptyCAHolder.cs
new file mode 100644 (file)
index 0000000..1114056
--- /dev/null
@@ -0,0 +1,17 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Reflection.Emit
+{
+    internal class EmptyCAHolder : ICustomAttributeProvider
+    {
+        internal EmptyCAHolder() { }
+
+        object[] ICustomAttributeProvider.GetCustomAttributes(Type attributeType, bool inherit) => Array.Empty<object>();
+
+        object[] ICustomAttributeProvider.GetCustomAttributes(bool inherit) => Array.Empty<object>();
+
+        bool ICustomAttributeProvider.IsDefined(Type attributeType, bool inherit) => false;
+    }
+}
index 29fbc8e..fc0b379 100644 (file)
@@ -513,15 +513,7 @@ namespace System.Reflection.Emit
             }
         }
 
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
-        public override ICustomAttributeProvider? ReturnTypeCustomAttributes
-        {
-            get
-            {
-                return null;
-            }
-        }
-#pragma warning restore CS8609
+        public override ICustomAttributeProvider ReturnTypeCustomAttributes => new EmptyCAHolder();
 
         public override Type? ReflectedType
         {
index a2573cc..a205cfd 100644 (file)
@@ -126,12 +126,7 @@ namespace System.Reflection.Emit
             }
         }
 
-#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268)
-        public override ICustomAttributeProvider? ReturnTypeCustomAttributes
-        {
-            get { return null; }
-        }
-#pragma warning restore CS8608
+        public override ICustomAttributeProvider ReturnTypeCustomAttributes => new EmptyCAHolder();
 
         public override object Invoke(object? obj, BindingFlags invokeAttr, Binder? binder, object?[]? parameters, CultureInfo? culture)
         {
index a03ec66..7404299 100644 (file)
@@ -444,15 +444,17 @@ namespace System.Resources
                 satAssemName += ", Version=" + _mediator.SatelliteContractVersion.ToString();
             }
 
-            byte[] token = _mediator.MainAssembly.GetName().GetPublicKeyToken()!;
-
-            int iLen = token.Length;
-            StringBuilder publicKeyTok = new StringBuilder(iLen * 2);
-            for (int i = 0; i < iLen; i++)
+            byte[]? token = _mediator.MainAssembly.GetName().GetPublicKeyToken();
+            if (token != null)
             {
-                publicKeyTok.Append(token[i].ToString("x", CultureInfo.InvariantCulture));
+                int iLen = token.Length;
+                StringBuilder publicKeyTok = new StringBuilder(iLen * 2);
+                for (int i = 0; i < iLen; i++)
+                {
+                    publicKeyTok.Append(token[i].ToString("x", CultureInfo.InvariantCulture));
+                }
+                satAssemName += ", PublicKeyToken=" + publicKeyTok;
             }
-            satAssemName += ", PublicKeyToken=" + publicKeyTok;
 
             Debug.Assert(_mediator.NeutralResourcesCulture != null);
             string missingCultureName = _mediator.NeutralResourcesCulture.Name;