Skip to content

Commit

Permalink
Merge pull request dotnet#24424 from MaStr11/FixLocalizationTestFailu…
Browse files Browse the repository at this point in the history
…res2

Localization test failures 2
  • Loading branch information
sharwell committed Feb 14, 2018
2 parents c05e6fb + 1528810 commit 5865312
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ static void F(object x)
Assert.Null(assembly);
AssertEx.Equal(new[]
{
"(1,5): error CS1733: Expected expression",
"(1,1): error CS1525: Invalid expression term '??'"
$"(1,5): error CS1733: { CSharpResources.ERR_ExpressionExpected }",
$"(1,1): error CS1525: { string.Format(CSharpResources.ERR_InvalidExprTerm, "??") }",
}, errorMessages);
Assert.True(methodTokens.IsEmpty);
Expand Down Expand Up @@ -195,8 +195,8 @@ static void F(object x)
Assert.Null(assembly);
AssertEx.Equal(new[]
{
"(1,1): error CS0103: The name 'z' does not exist in the current context",
"(1,6): error CS0103: The name 'z' does not exist in the current context"
$"(1,1): error CS0103: { string.Format(CSharpResources.ERR_NameNotInContext,"z") }",
$"(1,6): error CS0103: { string.Format(CSharpResources.ERR_NameNotInContext,"z") }",
}, errorMessages);
Assert.True(methodTokens.IsEmpty);
});
Expand Down Expand Up @@ -229,12 +229,12 @@ static void F()
Assert.Null(assembly);
AssertEx.Equal(new[]
{
$"error CS7013: Name '<{longName}>i__Field' exceeds the maximum length allowed in metadata.",
$"error CS7013: Name '<{longName}>j__TPar' exceeds the maximum length allowed in metadata.",
$"error CS7013: Name '<{longName}>i__Field' exceeds the maximum length allowed in metadata.",
$"error CS7013: Name 'get_{longName}' exceeds the maximum length allowed in metadata.",
$"error CS7013: Name '{longName}' exceeds the maximum length allowed in metadata.",
$"error CS7013: Name '{longName}' exceeds the maximum length allowed in metadata."
$"error CS7013: { string.Format(CSharpResources.ERR_MetadataNameTooLong, $"<{longName}>i__Field") }",
$"error CS7013: { string.Format(CSharpResources.ERR_MetadataNameTooLong, $"<{longName}>j__TPar") }",
$"error CS7013: { string.Format(CSharpResources.ERR_MetadataNameTooLong, $"<{longName}>i__Field") }",
$"error CS7013: { string.Format(CSharpResources.ERR_MetadataNameTooLong, $"get_{longName}") }",
$"error CS7013: { string.Format(CSharpResources.ERR_MetadataNameTooLong, $"{longName}") }",
$"error CS7013: { string.Format(CSharpResources.ERR_MetadataNameTooLong, $"{longName}") }",
}, errorMessages);
Assert.True(methodTokens.IsEmpty);
Expand Down Expand Up @@ -348,7 +348,7 @@ static void G(out object o)
out var errorMessages);
Assert.Null(assembly);
AssertEx.Equal(
new[] { "(1,11): error CS8185: A declaration is not allowed in this context." },
new[] { $"(1,11): error CS8185: { CSharpResources.ERR_DeclarationExpressionNotPermitted }" },
errorMessages);
Assert.True(methodTokens.IsEmpty);
});
Expand Down Expand Up @@ -380,9 +380,9 @@ static void F()
Assert.Null(assembly);
AssertEx.Equal(new[]
{
"(1,1): error CS0103: The name '$exception' does not exist in the current context",
"(1,1): error CS0103: The name '$1' does not exist in the current context",
"(1,7): error CS0103: The name '$unknown' does not exist in the current context",
$"(1,1): error CS0103: { string.Format(CSharpResources.ERR_NameNotInContext, "$exception") }",
$"(1,1): error CS0103: { string.Format(CSharpResources.ERR_NameNotInContext, "$1") }",
$"(1,7): error CS0103: { string.Format(CSharpResources.ERR_NameNotInContext, "$unknown") }",
}, errorMessages);
Assert.True(methodTokens.IsEmpty);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ void M()
out errorMessage);
Assert.Equal(2, numRetries); // Ensure that we actually retried and that we bailed out on the second retry if the same identity was seen in the diagnostics.
Assert.Equal($"error CS0012: The type 'MissingType' is defined in an assembly that is not referenced. You must add a reference to assembly '{missingIdentity}'.", errorMessage);
Assert.Equal($"error CS0012: { string.Format(CSharpResources.ERR_NoTypeDef, "MissingType", missingIdentity)}", errorMessage);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,22 +365,28 @@ static void M()

// Duplicate type in namespace, at type scope.
ExpressionCompilerTestHelpers.CompileExpressionWithRetry(blocks, "new N.C1()", ImmutableArray<Alias>.Empty, contextFactory, getMetaDataBytesPtr: null, errorMessage: out errorMessage, testData: out testData);
Assert.True(errorMessage.StartsWith("error CS0433: The type 'C1' exists in both "));

IEnumerable<string> CS0433Messages(string type)
{
yield return "error CS0433: " + string.Format(CSharpResources.ERR_SameFullNameAggAgg, compilationA.Assembly.Identity, type, compilationB.Assembly.Identity);
yield return "error CS0433: " + string.Format(CSharpResources.ERR_SameFullNameAggAgg, compilationB.Assembly.Identity, type, compilationA.Assembly.Identity);
}
Assert.Contains(errorMessage, CS0433Messages("C1"));

GetContextState(runtime, "B.M", out blocks, out moduleVersionId, out symReader, out methodToken, out localSignatureToken);
contextFactory = CreateMethodContextFactory(moduleVersionId, symReader, methodToken, localSignatureToken);

// Duplicate type in namespace, at method scope.
ExpressionCompilerTestHelpers.CompileExpressionWithRetry(blocks, "new C1()", ImmutableArray<Alias>.Empty, contextFactory, getMetaDataBytesPtr: null, errorMessage: out errorMessage, testData: out testData);
Assert.True(errorMessage.StartsWith("error CS0433: The type 'C1' exists in both "));
Assert.Contains(errorMessage, CS0433Messages("C1"));

// Duplicate type in global namespace, at method scope.
ExpressionCompilerTestHelpers.CompileExpressionWithRetry(blocks, "new C2()", ImmutableArray<Alias>.Empty, contextFactory, getMetaDataBytesPtr: null, errorMessage: out errorMessage, testData: out testData);
Assert.True(errorMessage.StartsWith("error CS0433: The type 'C2' exists in both "));
Assert.Contains(errorMessage, CS0433Messages("C2"));

// Duplicate extension method, at method scope.
ExpressionCompilerTestHelpers.CompileExpressionWithRetry(blocks, "x.F()", ImmutableArray<Alias>.Empty, contextFactory, getMetaDataBytesPtr: null, errorMessage: out errorMessage, testData: out testData);
Assert.Equal(errorMessage, "error CS0121: The call is ambiguous between the following methods or properties: 'N.E.F(A)' and 'N.E.F(A)'");
Assert.Equal($"error CS0121: { string.Format(CSharpResources.ERR_AmbigCall, "N.E.F(A)", "N.E.F(A)") }", errorMessage);

// Same tests as above but in library that does not directly reference duplicates.
GetContextState(runtime, "A", out blocks, out moduleVersionId, out symReader, out typeToken, out localSignatureToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ End Class
errorMessage)

Assert.Equal(2, numRetries) ' Ensure that we actually retried and that we bailed out on the second retry if the same identity was seen in the diagnostics.
Assert.Equal($"error BC30652: Reference required to assembly '{missingIdentity}' containing the type 'MissingType'. Add one to your project.", errorMessage)
Assert.Equal($"error BC30652: { String.Format(VBResources.ERR_UnreferencedAssembly3, missingIdentity, "MissingType")}", errorMessage)
End Sub)
End Sub

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,22 +220,22 @@ End Class"
Dim testData As CompilationTestData = Nothing
Dim errorMessage As String = Nothing
ExpressionCompilerTestHelpers.CompileExpressionWithRetry(blocks, "New N.C1()", ImmutableArray(Of [Alias]).Empty, contextFactory, getMetaDataBytesPtr:=Nothing, errorMessage:=errorMessage, testData:=testData)
Assert.Equal(errorMessage, "error BC30560: 'C1' is ambiguous in the namespace 'N'.")
Assert.Equal($"error BC30560: { String.Format(VBResources.ERR_AmbiguousInNamespace2, "C1", "N") }", errorMessage)

GetContextState(runtime, "B.Main", blocks, moduleVersionId, symReader, methodToken, localSignatureToken)
contextFactory = CreateMethodContextFactory(moduleVersionId, symReader, methodToken, localSignatureToken)

' Duplicate type in namespace, at method scope.
ExpressionCompilerTestHelpers.CompileExpressionWithRetry(blocks, "New C1()", ImmutableArray(Of [Alias]).Empty, contextFactory, getMetaDataBytesPtr:=Nothing, errorMessage:=errorMessage, testData:=testData)
Assert.Equal(errorMessage, "error BC30560: 'C1' is ambiguous in the namespace 'N'.")
Assert.Equal($"error BC30560: { String.Format(VBResources.ERR_AmbiguousInNamespace2, "C1", "N") }", errorMessage)

' Duplicate type in global namespace, at method scope.
ExpressionCompilerTestHelpers.CompileExpressionWithRetry(blocks, "New C2()", ImmutableArray(Of [Alias]).Empty, contextFactory, getMetaDataBytesPtr:=Nothing, errorMessage:=errorMessage, testData:=testData)
Assert.Equal(errorMessage, "error BC30554: 'C2' is ambiguous.")
Assert.Equal($"error BC30554: { String.Format(VBResources.ERR_AmbiguousInUnnamedNamespace1, "C2") }", errorMessage)

' Duplicate extension method, at method scope.
ExpressionCompilerTestHelpers.CompileExpressionWithRetry(blocks, "x.F()", ImmutableArray(Of [Alias]).Empty, contextFactory, getMetaDataBytesPtr:=Nothing, errorMessage:=errorMessage, testData:=testData)
Assert.True(errorMessage.StartsWith("error BC30521: Overload resolution failed because no accessible 'F' is most specific for these arguments:"))
Assert.True(errorMessage.StartsWith($"error BC30521: { String.Format(VBResources.ERR_NoMostSpecificOverload2, "F", "") }"))

' Same tests as above but in library that does not directly reference duplicates.
GetContextState(runtime, "A", blocks, moduleVersionId, symReader, typeToken, localSignatureToken)
Expand Down

0 comments on commit 5865312

Please sign in to comment.