Support generics in analyzer - #1854
Conversation
|
Must still improve: won't work in the example when using I didn't check the impact on the developer branch with v3, can look at it if requested |
|
Thanks for contributing. |
|
Unfortunately I'm not sure to understand how analyzer are supposed to work on develop - I don't manage to have it running on sandbox project and am less familiar with SourceGenerator. // Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using MessagePack;
namespace ConsoleApp1;
public class Program
{
[MessagePackObject]
public class A
{
public int Member { get; set; }
}
public static void Main(string[] args)
{
var bytes = MessagePackSerializer.Serialize(new A { Member = 10 });
var b = MessagePackSerializer.Deserialize<A>(bytes);
Console.WriteLine(b.Member == 10);
}
}<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\MessagePack.Analyzers\MessagePack.Analyzers.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false" />
<ProjectReference Include="..\..\src\MessagePack\MessagePack.csproj" />
</ItemGroup>
</Project>I don't get any warning/error at compilation for missing Key/IgnoreMember attributes, which would then crash at runtime. |
|
#1859 adds the test and fixes the bug for v3. |

fixes #1853