Skip to content

Analyzer does not work if only MessagePack.Annotations is referenced. #1672

@N-Olbert

Description

@N-Olbert

Bug description

The analyzer does not produce any diagnostics if only MessagePack.Annotations (instead of the "full" MessagePack) is referenced.

Repro steps

*.csproj

  <ItemGroup>
    <PackageReference Include="MessagePack.Annotations" Version="2.5.124" />
    <PackageReference Include="MessagePackAnalyzer" Version="2.5.124">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

Foo.cs

using MessagePack;

namespace XYZ;

[MessagePackObject]
public class Foo
{
    [Key(0)]
    public int Foo1 { get; set; }

    // NOTE: No diagnostic reported!
    public int Foo2 { get; set; }
}

Expected behavior

MsgPack004-Diagonsitc reported on Foo.Foo2.

Actual behavior

No diagonstic is reported.

Additional context

If you change <PackageReference Include="MessagePack.Annotations" Version="2.5.124" /> to <PackageReference Include="MessagePack" Version="2.5.124" /> it works as expected (but I don`t want to do this).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions