提交 412caa97 编写于 作者: B BattleRush

Code review changes

上级 2b433bec
......@@ -5560,6 +5560,15 @@ internal class CSharpResources {
}
}
/// <summary>
/// Looks up a localized string similar to Unable to read debug information of method &apos;{0}&apos; (token 0x{1}) from assembly &apos;{2}&apos;.
/// </summary>
internal static string ERR_InvalidDebugInfo {
get {
return ResourceManager.GetString("ERR_InvalidDebugInfo", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Invalid debug information format: {0}.
/// </summary>
......
......@@ -5076,4 +5076,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="ERR_LocalFunctionMissingBody" xml:space="preserve">
<value>'{0}' is a local function and must therefore always have a body.</value>
</data>
<data name="ERR_InvalidDebugInfo" xml:space="preserve">
<value>Unable to read debug information of method '{0}' (token 0x{1}) from assembly '{2}'</value>
</data>
</root>
\ No newline at end of file
......@@ -1240,6 +1240,7 @@ internal enum ErrorCode
ERR_InvalidAssemblyCulture = 7100,
ERR_EncReferenceToAddedMember = 7101,
ERR_MutuallyExclusiveOptions = 7102,
ERR_InvalidDebugInfo = 7103,
#endregion diagnostics introduced in C# 6
// huge gap here; unused 7103-8000
......@@ -1343,7 +1344,7 @@ internal enum ErrorCode
#region diagnostics for local functions introduced in C# 7
ERR_DynamicLocalFunctionParamsParameter = 8108,
ERR_ExpressionTreeContainsLocalFunction = 8110,
ERR_LocalFunctionMissingBody = 8111, //https://github.com/dotnet/roslyn/issues/14900
ERR_LocalFunctionMissingBody = 8111,
#endregion diagnostics for local functions introduced in C# 7
#region diagnostics for instrumentation
......
......@@ -218,6 +218,7 @@ public override void ReportDuplicateMetadataReferenceWeak(DiagnosticBag diagnost
public override int ERR_PeWritingFailure => (int)ErrorCode.ERR_PeWritingFailure;
public override int ERR_ModuleEmitFailure => (int)ErrorCode.ERR_ModuleEmitFailure;
public override int ERR_EncUpdateFailedMissingAttribute => (int)ErrorCode.ERR_EncUpdateFailedMissingAttribute;
public override int ERR_InvalidDebugInfo => (int)ErrorCode.ERR_InvalidDebugInfo;
public override void ReportInvalidAttributeArgument(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, int parameterIndex, AttributeData attribute)
{
......
......@@ -7133,15 +7133,9 @@ static void F()
generation0,
ImmutableArray.Create(new SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true)));
// TODO: better error code https://github.com/dotnet/roslyn/issues/11512
string expectedMessage = string.Format(CodeAnalysisResources.UnableToReadDebugInfo,
"C.F()",
"06000001",
"PdbReadingErrorsAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
diff1.EmitResult.Diagnostics.Verify(
// (6,14): error CS7038: Failed to emit module 'Unable to read debug information of method 'C.F()' (token 0x06000001) from assembly 'PdbReadingErrorsAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null''.
Diagnostic(ErrorCode.ERR_ModuleEmitFailure, "F").WithArguments(expectedMessage).WithLocation(6, 14));
Diagnostic(ErrorCode.ERR_InvalidDebugInfo, "F").WithArguments("C.F()", "06000001", "PdbReadingErrorsAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(6, 14));
}
[Fact]
......
......@@ -1441,15 +1441,6 @@ internal class CodeAnalysisResources {
}
}
/// <summary>
/// Looks up a localized string similar to Unable to read debug information of method &apos;{0}&apos; (token 0x{1}) from assembly &apos;{2}&apos;.
/// </summary>
internal static string UnableToReadDebugInfo {
get {
return ResourceManager.GetString("UnableToReadDebugInfo", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to A node in the list is not of the expected type..
/// </summary>
......
......@@ -594,9 +594,6 @@
<data name="Stream_contains_invalid_data" xml:space="preserve">
<value>Stream contains invalid data</value>
</data>
<data name="UnableToReadDebugInfo" xml:space="preserve">
<value>Unable to read debug information of method '{0}' (token 0x{1}) from assembly '{2}'</value>
</data>
<data name="CannotCallWhenQueueIsCompleted" xml:space="preserve">
<value>Cannot call {0} when the queue is already completed.</value>
</data>
......
......@@ -220,6 +220,7 @@ public DiagnosticInfo FilterDiagnosticInfo(DiagnosticInfo diagnosticInfo, Compil
public abstract int ERR_PeWritingFailure { get; }
public abstract int ERR_ModuleEmitFailure { get; }
public abstract int ERR_EncUpdateFailedMissingAttribute { get; }
public abstract int ERR_InvalidDebugInfo { get; }
/// <summary>
/// Takes an exception produced while writing to a file stream and produces a diagnostic.
......
......@@ -233,16 +233,12 @@ internal VariableSlotAllocator TryCreateVariableSlotAllocator(EmitBaseline basel
}
catch (InvalidDataException)
{
string message = string.Format(CodeAnalysisResources.UnableToReadDebugInfo,
MessageProvider.GetErrorDisplayString(method),
MetadataTokens.GetToken(previousHandle).ToString("X8"),
MessageProvider.GetErrorDisplayString(method.ContainingAssembly));
//TODO: use better error code (https://github.com/dotnet/roslyn/issues/11512)
diagnostics.Add(MessageProvider.CreateDiagnostic(
MessageProvider.ERR_ModuleEmitFailure,
MessageProvider.ERR_InvalidDebugInfo,
method.Locations.First(),
message
MessageProvider.GetErrorDisplayString(method),
MetadataTokens.GetToken(previousHandle).ToString("X8"),
MessageProvider.GetErrorDisplayString(method.ContainingAssembly)
));
return null;
......
......@@ -1731,6 +1731,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
ERR_BadLanguageVersion = 37287
ERR_InvalidPreprocessorConstantType = 37288
ERR_TupleInferredNamesNotAvailable = 37289
ERR_InvalidDebugInfo = 37290
'// WARNINGS BEGIN HERE
WRN_UseOfObsoleteSymbol2 = 40000
......
......@@ -545,6 +545,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return ERRID.ERR_BadAssemblyName
End Get
End Property
Public Overrides ReadOnly Property ERR_InvalidDebugInfo As Integer
Get
Return ERRID.ERR_InvalidDebugInfo
End Get
End Property
End Class
End Namespace
......@@ -5918,6 +5918,15 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Unable to read debug information of method &apos;{0}&apos; (token 0x{1}) from assembly &apos;{2}&apos;.
'''</summary>
Friend ReadOnly Property ERR_InvalidDebugInfo() As String
Get
Return ResourceManager.GetString("ERR_InvalidDebugInfo", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Invalid debug information format: {0}.
'''</summary>
......
......@@ -5484,4 +5484,8 @@
<data name="WRN_Experimental_Title" xml:space="preserve">
<value>Type is for evaluation purposes only and is subject to change or removal in future updates.</value>
</data>
<data name="ERR_InvalidDebugInfo" xml:space="preserve">
<value>Unable to read debug information of method '{0}' (token 0x{1}) from assembly '{2}'</value>
</data>
</root>
......@@ -441,5 +441,13 @@ public override int ERR_BadDocumentationMode
throw new NotImplementedException();
}
}
public override int ERR_InvalidDebugInfo
{
get
{
throw new NotImplementedException();
}
}
}
}
......@@ -65,6 +65,11 @@ internal sealed class DocumentationComment
/// </summary>
public string CompletionListCref { get; private set; }
/// <summary>
/// Used for TrimEachLine(string text) method, to prevent new allocation of string
/// </summary>
private static string NewLineString = Environment.NewLine;
private DocumentationComment()
{
ParameterNames = ImmutableArray<string>.Empty;
......@@ -157,7 +162,7 @@ private static void ParseCallback(XmlReader reader, CommentBuilder builder)
private string TrimEachLine(string text)
{
return string.Join(Environment.NewLine, text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).Select(i => i.Trim()));
return string.Join(NewLineString, text.Split(new string[] { NewLineString }, StringSplitOptions.RemoveEmptyEntries).Select(i => i.Trim()));
}
private void ParseCallback(XmlReader reader)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册