Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced message parameter of CSharpCompilerError with WithMessage() #2136

Merged
merged 1 commit into from
May 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public async Task TestRegressionMethodGlobalNamespaceAsync(string code, int colu

DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS0116", "A namespace cannot directly contain members such as fields or methods").WithLocation(4, column),
this.CSharpCompilerError("CS0116").WithMessage("A namespace cannot directly contain members such as fields or methods").WithLocation(4, column),
this.CSharpDiagnostic().WithLocation(4, column),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ public string MethodName

DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS1002", "; expected").WithLocation(5, 29),
this.CSharpCompilerError("CS1002").WithMessage("; expected").WithLocation(5, 29),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ public DiagnosticResult WithArguments(params object[] arguments)
return result;
}

public DiagnosticResult WithMessage(string message)
{
DiagnosticResult result = this;
result.Message = message;
return result;
}

public DiagnosticResult WithMessageFormat(LocalizableString messageFormat)
{
DiagnosticResult result = this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,12 @@ protected DiagnosticResult CSharpDiagnostic(DiagnosticDescriptor descriptor)
return new DiagnosticResult(descriptor);
}

protected DiagnosticResult CSharpCompilerError(string errorIdentifier, string message)
protected DiagnosticResult CSharpCompilerError(string errorIdentifier)
{
return new DiagnosticResult
{
Id = errorIdentifier,
Severity = DiagnosticSeverity.Error,
Message = message,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public int Prop
}";
DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS0501", "'Foo.Prop.get' must declare a body because it is not marked abstract, extern, or partial").WithLocation(6, 9),
this.CSharpCompilerError("CS0501").WithMessage("'Foo.Prop.get' must declare a body because it is not marked abstract, extern, or partial").WithLocation(6, 9),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -851,10 +851,10 @@ public class TestClass /

DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS1022", "Type or namespace definition, or end-of-file expected").WithLocation(3, 28),
this.CSharpCompilerError("CS1513", "} expected").WithLocation(3, 28),
this.CSharpCompilerError("CS1514", "{ expected").WithLocation(3, 28),
this.CSharpCompilerError("CS1022", "Type or namespace definition, or end-of-file expected").WithLocation(6, 1),
this.CSharpCompilerError("CS1022").WithMessage("Type or namespace definition, or end-of-file expected").WithLocation(3, 28),
this.CSharpCompilerError("CS1513").WithMessage("} expected").WithLocation(3, 28),
this.CSharpCompilerError("CS1514").WithMessage("{ expected").WithLocation(3, 28),
this.CSharpCompilerError("CS1022").WithMessage("Type or namespace definition, or end-of-file expected").WithLocation(6, 1),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -936,8 +936,8 @@ public string
// We don't care about the syntax errors.
var expected = new[]
{
this.CSharpCompilerError("CS1585", "Member modifier 'public' must precede the member type and name").WithLocation(5, 5),
this.CSharpCompilerError("CS1519", "Invalid token '}' in class, struct, or interface member declaration").WithLocation(6, 1),
this.CSharpCompilerError("CS1585").WithMessage("Member modifier 'public' must precede the member type and name").WithLocation(5, 5),
this.CSharpCompilerError("CS1519").WithMessage("Invalid token '}' in class, struct, or interface member declaration").WithLocation(6, 1),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand All @@ -961,8 +961,8 @@ public string
// We don't care about the syntax errors.
DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS1585", "Member modifier 'public' must precede the member type and name").WithLocation(5, 5),
this.CSharpCompilerError("CS1519", "Invalid token '}' in class, struct, or interface member declaration").WithLocation(6, 1),
this.CSharpCompilerError("CS1585").WithMessage("Member modifier 'public' must precede the member type and name").WithLocation(5, 5),
this.CSharpCompilerError("CS1519").WithMessage("Invalid token '}' in class, struct, or interface member declaration").WithLocation(6, 1),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ public static string
// We don't care about the syntax errors.
DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS1585", "Member modifier 'public' must precede the member type and name").WithLocation(5, 5),
this.CSharpCompilerError("CS1519", "Invalid token '}' in class, struct, or interface member declaration").WithLocation(6, 1),
this.CSharpCompilerError("CS1585").WithMessage("Member modifier 'public' must precede the member type and name").WithLocation(5, 5),
this.CSharpCompilerError("CS1519").WithMessage("Invalid token '}' in class, struct, or interface member declaration").WithLocation(6, 1),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public async Task TestWithIncompleteMembersAsync()

DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS1519", "Invalid token '}' in class, struct, or interface member declaration").WithLocation(4, 1),
this.CSharpCompilerError("CS1519").WithMessage("Invalid token '}' in class, struct, or interface member declaration").WithLocation(4, 1),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class Foo

DiagnosticResult[] expected =
{
this.CSharpCompilerError(id, message).WithLocation(4, column),
this.CSharpCompilerError(id).WithMessage(message).WithLocation(4, column),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ void MethodName()

DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS0742", "A query body must end with a select clause or a group clause").WithLocation(6, 42),
this.CSharpCompilerError("CS0742").WithMessage("A query body must end with a select clause or a group clause").WithLocation(6, 42),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void MethodName()

DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS1003", "Syntax error, ',' expected").WithLocation(6, 25),
this.CSharpCompilerError("CS1003").WithMessage("Syntax error, ',' expected").WithLocation(6, 25),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ int x

DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS1002", "; expected").WithLocation(6, 14),
this.CSharpCompilerError("CS1002").WithMessage("; expected").WithLocation(6, 14),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static explicit bool(ClassName x)

DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS1003", "Syntax error, 'operator' expected").WithLocation(4, 28),
this.CSharpCompilerError("CS1003").WithMessage("Syntax error, 'operator' expected").WithLocation(4, 28),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2026,7 +2026,7 @@ class ClassName

DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS1003", "Syntax error, '(' expected").WithLocation(5, 15),
this.CSharpCompilerError("CS1003").WithMessage("Syntax error, '(' expected").WithLocation(5, 15),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ class ClassName

DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS1026", ") expected").WithLocation(5, 16),
this.CSharpCompilerError("CS1026").WithMessage(") expected").WithLocation(5, 16),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ void Method()

DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS0443", "Syntax error; value expected").WithLocation(6, 28),
this.CSharpCompilerError("CS1003", "Syntax error, ',' expected").WithLocation(6, 28),
this.CSharpCompilerError("CS1003", "Syntax error, ']' expected").WithLocation(6, 28),
this.CSharpCompilerError("CS0443").WithMessage("Syntax error; value expected").WithLocation(6, 28),
this.CSharpCompilerError("CS1003").WithMessage("Syntax error, ',' expected").WithLocation(6, 28),
this.CSharpCompilerError("CS1003").WithMessage("Syntax error, ']' expected").WithLocation(6, 28),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void Method()

DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS1514", "{ expected").WithLocation(6, 25),
this.CSharpCompilerError("CS1514").WithMessage("{ expected").WithLocation(6, 25),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ class ClassName

DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS1513", "} expected").WithLocation(3, 2),
this.CSharpCompilerError("CS1513").WithMessage("} expected").WithLocation(3, 2),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ void Method()

DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS1003", "Syntax error, '>' expected").WithLocation(7, 35),
this.CSharpCompilerError("CS1003").WithMessage("Syntax error, '>' expected").WithLocation(7, 35),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private void Test()

DiagnosticResult[] expected =
{
this.CSharpCompilerError("CS1031", "Type expected").WithLocation(10, 2),
this.CSharpCompilerError("CS1031").WithMessage("Type expected").WithLocation(10, 2),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
Expand Down