Review feedback
authorDavid Wrighton <davidwr@microsoft.com>
Sat, 21 Sep 2019 01:07:55 +0000 (18:07 -0700)
committerDavid Wrighton <davidwr@microsoft.com>
Sat, 21 Sep 2019 01:07:55 +0000 (18:07 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/b0c0f9cde3c3f6f7500d268030a99137d8e4ea64

src/coreclr/src/tools/crossgen2/Common/TypeSystem/Common/MethodDesc.ToString.Diagnostic.cs [deleted file]
src/coreclr/src/tools/crossgen2/Common/TypeSystem/Common/MethodDesc.ToString.cs
src/coreclr/src/tools/crossgen2/Common/TypeSystem/Common/TypeDesc.ToString.cs
src/coreclr/src/tools/crossgen2/Common/TypeSystem/Common/Utilities/DebugNameFormatter.Diagnostic.cs [deleted file]
src/coreclr/src/tools/crossgen2/Common/TypeSystem/Common/Utilities/DebugNameFormatter.cs
src/coreclr/src/tools/crossgen2/Common/TypeSystem/Common/Utilities/TypeNameFormatter.cs
src/coreclr/src/tools/crossgen2/ILCompiler.TypeSystem.ReadyToRun/ILCompiler.TypeSystem.ReadyToRun.csproj

diff --git a/src/coreclr/src/tools/crossgen2/Common/TypeSystem/Common/MethodDesc.ToString.Diagnostic.cs b/src/coreclr/src/tools/crossgen2/Common/TypeSystem/Common/MethodDesc.ToString.Diagnostic.cs
deleted file mode 100644 (file)
index d1bb25d..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// 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.
-
-using System.Text;
-
-namespace Internal.TypeSystem
-{
-    partial class MethodDesc
-    {
-        partial void GetDiagnosticName(ref string diagnosticName)
-        {
-            diagnosticName = DiagnosticName;
-        }
-    }
-}
index 3f7c8b3..c243fff 100644 (file)
@@ -19,7 +19,7 @@ namespace Internal.TypeSystem
 
             if (includeReturnType)
             {
-                DebugNameFormatter.Instance.AppendName(sb, ReturnType, DebugNameFormatter.FormatOptions.None | DebugNameFormatter.FormatOptions.UseDiagnosticName);
+                DebugNameFormatter.Instance.AppendName(sb, ReturnType, DebugNameFormatter.FormatOptions.None);
                 sb.Append('(');
             }
 
@@ -30,7 +30,7 @@ namespace Internal.TypeSystem
                     first = false;
                 else
                     sb.Append(',');
-                DebugNameFormatter.Instance.AppendName(sb, param, DebugNameFormatter.FormatOptions.None | DebugNameFormatter.FormatOptions.UseDiagnosticName);
+                DebugNameFormatter.Instance.AppendName(sb, param, DebugNameFormatter.FormatOptions.None);
             }
 
             if (includeReturnType)
@@ -55,10 +55,12 @@ namespace Internal.TypeSystem
             }
             catch
             {
-                string diagName = null;
-                GetDiagnosticName(ref diagName);
-                if (diagName == null)
-                    throw;
+                string diagName = "Unknown";
+                try
+                {
+                    diagName = DiagnosticName;
+                }
+                catch {}
                 sb.Append(diagName);
             }
 
@@ -74,7 +76,7 @@ namespace Internal.TypeSystem
                 {
                     sb.Append(',');
                 }
-                DebugNameFormatter.Instance.AppendName(sb, Instantiation[i], DebugNameFormatter.FormatOptions.None | DebugNameFormatter.FormatOptions.UseDiagnosticName);
+                DebugNameFormatter.Instance.AppendName(sb, Instantiation[i], DebugNameFormatter.FormatOptions.None);
             }
             if (!first)
                 sb.Append('>');
@@ -92,7 +94,5 @@ namespace Internal.TypeSystem
 
             return sb.ToString();
         }
-
-        partial void GetDiagnosticName(ref string diagnosticName);
     }
 }
index 6fe094a..34e616f 100644 (file)
@@ -8,7 +8,7 @@ namespace Internal.TypeSystem
     {
         public override string ToString()
         {
-            return DebugNameFormatter.Instance.FormatName(this, DebugNameFormatter.FormatOptions.Default | DebugNameFormatter.FormatOptions.UseDiagnosticName);
+            return DebugNameFormatter.Instance.FormatName(this, DebugNameFormatter.FormatOptions.Default);
         }
     }
 }
diff --git a/src/coreclr/src/tools/crossgen2/Common/TypeSystem/Common/Utilities/DebugNameFormatter.Diagnostic.cs b/src/coreclr/src/tools/crossgen2/Common/TypeSystem/Common/Utilities/DebugNameFormatter.Diagnostic.cs
deleted file mode 100644 (file)
index e362b9d..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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.
-
-using System;
-using System.Text;
-
-using Debug = System.Diagnostics.Debug;
-
-namespace Internal.TypeSystem
-{
-    partial class DebugNameFormatter
-    {
-        partial void GetDiagnosticName(GenericParameterDesc type, ref string diagnosticName)
-        {
-            try
-            {
-                diagnosticName = type.DiagnosticName;
-            }
-            catch {}
-        }
-
-        partial void GetDiagnosticName(DefType type, ref string diagnosticName)
-        {
-            try
-            {
-                diagnosticName = type.DiagnosticName;
-            }
-            catch {}
-        }
-    }
-}
index 187a97b..5b83ab0 100644 (file)
@@ -11,9 +11,6 @@ namespace Internal.TypeSystem
 {
     public partial class DebugNameFormatter : TypeNameFormatter<DebugNameFormatter.Void, DebugNameFormatter.FormatOptions>
     {
-        partial void GetDiagnosticName(GenericParameterDesc type, ref string diagnosticName);
-        partial void GetDiagnosticName(DefType type, ref string diagnosticName);
-
         public static readonly DebugNameFormatter Instance = new DebugNameFormatter();
 
         public override Void AppendName(StringBuilder sb, ArrayType type, FormatOptions options)
@@ -74,7 +71,7 @@ namespace Internal.TypeSystem
             {
                 sb.Append(type.Name);
             }
-            catch when ((options & FormatOptions.UseDiagnosticName) != 0)
+            catch
             {
                 string diagnosticName = "Unknown";
                 GetDiagnosticName(type, ref diagnosticName);
@@ -112,7 +109,7 @@ namespace Internal.TypeSystem
             {
                 sb.Append(nestedType.Name);
             }
-            catch when ((options & FormatOptions.UseDiagnosticName) != 0)
+            catch
             {
                 string diagnosticName = "Unknown";
                 GetDiagnosticName(nestedType, ref diagnosticName);
@@ -203,7 +200,7 @@ namespace Internal.TypeSystem
 
                 sb.Append(type.Name);
             }
-            catch when ((options & FormatOptions.UseDiagnosticName) != 0)
+            catch
             {
                 sb.Length = initialLen;
 
@@ -230,7 +227,7 @@ namespace Internal.TypeSystem
                 {
                     assemblyName = ((IAssemblyDesc)mdType.Module).GetName().Name;
                 }
-                catch when ((options & FormatOptions.UseDiagnosticName) != 0)
+                catch
                 {
                     assemblyName = "Unknown";
                 }
@@ -270,12 +267,30 @@ namespace Internal.TypeSystem
             {
                 return possibleInnerType.ContainingType;
             }
-            catch when ((options & FormatOptions.UseDiagnosticName) != 0)
+            catch
             {
                 return null;
             }
         }
 
+        private void GetDiagnosticName(GenericParameterDesc type, ref string diagnosticName)
+        {
+            try
+            {
+                diagnosticName = type.DiagnosticName;
+            }
+            catch {}
+        }
+
+        private void GetDiagnosticName(DefType type, ref string diagnosticName)
+        {
+            try
+            {
+                diagnosticName = type.DiagnosticName;
+            }
+            catch {}
+        }
+
         public struct Void
         {
             public static Void Value => default(Void);
index 19b45fe..ea84155 100644 (file)
@@ -88,11 +88,9 @@ namespace Internal.TypeSystem
         public TState AppendName(StringBuilder sb, TypeDesc type, TOptions options)
         {
             TypeFlags category;
-            bool normalCategoryComputation = false;
             try
             {
                 category = type.Category;
-                normalCategoryComputation = true;
             }
             catch
             {
@@ -127,7 +125,6 @@ namespace Internal.TypeSystem
                 case TypeFlags.SignatureMethodVariable:
                     return AppendName(sb, (SignatureMethodVariable)type, options);
                 default:
-                    Debug.Assert(normalCategoryComputation && type.IsDefType); // Don't call type.IsDefType if Category computation failed
                     return AppendName(sb, (DefType)type, options);
             }
         }
index c6cd57e..d130008 100644 (file)
     <Compile Include="..\Common\TypeSystem\Common\Utilities\DebugNameFormatter.cs">
       <Link>Utilities\DebugNameFormatter.cs</Link>
     </Compile>
-    <Compile Include="..\Common\TypeSystem\Common\Utilities\DebugNameFormatter.Diagnostic.cs">
-      <Link>Utilities\DebugNameFormatter.Diagnostic.cs</Link>
-    </Compile>
     <Compile Include="..\Common\TypeSystem\Common\Utilities\LockFreeReaderHashtable.cs">
       <Link>Utilities\LockFreeReaderHashtable.cs</Link>
     </Compile>
     <Compile Include="..\Common\TypeSystem\Common\MethodDesc.ToString.cs">
       <Link>TypeSystem\Common\MethodDesc.ToString.cs</Link>
     </Compile>
-    <Compile Include="..\Common\TypeSystem\Common\MethodDesc.ToString.Diagnostic.cs">
-      <Link>TypeSystem\Common\MethodDesc.ToString.Diagnostic.cs</Link>
-    </Compile>
     <Compile Include="..\Common\TypeSystem\Common\MetadataVirtualMethodAlgorithm.cs">
       <Link>TypeSystem\Common\StandardVirtualMethodAlgorithm.cs</Link>
     </Compile>