Skip to content
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 @@ -183,8 +183,8 @@ private static void AnalyzeMember(
context.ReportDiagnostic(Diagnostic.Create(
Descriptor,
location,
explicitContractType.ToDisplayString(SymbolDisplayFormat.CSharpShortErrorMessageFormat),
expectedType.ToDisplayString(SymbolDisplayFormat.CSharpShortErrorMessageFormat)));
explicitContractType.ToDisplayString(FullyQualifiedTypeNameFormat),
expectedType.ToDisplayString(FullyQualifiedTypeNameFormat)));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Composition.Analyzers;
using VerifyCS = CSharpCodeFixVerifier<Microsoft.VisualStudio.Composition.Analyzers.VSMEF008ImportContractTypeMismatchAnalyzer, Microsoft.CodeAnalysis.Testing.EmptyCodeFixProvider>;

public class VSMEF008ImportContractTypeMismatchAnalyzerTests
Expand Down Expand Up @@ -280,4 +281,30 @@ class Foo
("vs-mef.ContractNamesAssignability.txt", SourceText.From(allowList)));
await verifier.RunAsync();
}

[Fact]
public async Task DiagnosticMessage_UsesFullyQualifiedTypeNames()
{
string test = """
using System.ComponentModel.Composition;

namespace MyCompany.Services
{
interface IServiceBroker { }
class SVsServiceProvider { }

class Foo
{
[Import(typeof(SVsServiceProvider))]
public IServiceBroker {|#0:Value|} { get; set; }
}
}
""";

await VerifyCS.VerifyAnalyzerAsync(
test,
VerifyCS.Diagnostic(VSMEF008ImportContractTypeMismatchAnalyzer.Id)
.WithLocation(0)
.WithArguments("MyCompany.Services.SVsServiceProvider", "MyCompany.Services.IServiceBroker"));
}
}