Visitar URL original
Fix analyzer when only MessagePack.Annotations is referenced by AArnott · Pull Request #1674 · MessagePack-CSharp/MessagePack-CSharp · GitHub
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
6 changes: 1 addition & 5 deletions src/MessagePack.Analyzers/CodeAnalysis/ReferenceSymbols.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public record ReferenceSymbols(
INamedTypeSymbol KeyAttribute,
INamedTypeSymbol IgnoreAttribute,
INamedTypeSymbol FormatterAttribute,
INamedTypeSymbol MessagePackFormatter,
INamedTypeSymbol? MessagePackFormatter,
INamedTypeSymbol? IgnoreDataMemberAttribute,
INamedTypeSymbol IMessagePackSerializationCallbackReceiver)
{
Expand Down Expand Up @@ -58,10 +58,6 @@ public static bool TryCreate(Compilation compilation, [NotNullWhen(true)] out Re
}

INamedTypeSymbol? messageFormatter = compilation.GetTypeByMetadataName("MessagePack.Formatters.IMessagePackFormatter");
if (messageFormatter is null)
{
return false;
}

INamedTypeSymbol? ignoreDataMemberAttribute = compilation.GetTypeByMetadataName("System.Runtime.Serialization.IgnoreDataMemberAttribute");

Expand Down
4 changes: 4 additions & 0 deletions tests/MessagePack.Analyzers.Tests/Helpers/ReferencesHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ internal static class ReferencesHelper
internal static ReferenceAssemblies DefaultReferences = ReferenceAssemblies.NetFramework.Net472.Default
.AddPackages(ImmutableArray.Create(
new PackageIdentity("MessagePack", "2.0.335")));

internal static ReferenceAssemblies AnnotationsOnly = ReferenceAssemblies.NetFramework.Net472.Default
.AddPackages(ImmutableArray.Create(
new PackageIdentity("MessagePack.Annotations", "2.0.335")));
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ public class Bar : Foo

await new VerifyCS.Test
{
ReferenceAssemblies = ReferencesHelper.AnnotationsOnly,
CodeFixTestBehaviors = CodeFixTestBehaviors.SkipLocalDiagnosticCheck, // BUGBUG: move diagnostic to `Foo` reference in Bar's base type list.
TestState =
{
Expand Down