Skip to content

Array of arrays member in MessagePackObject-annotated class causes build failure with NuGet package version >=v3.0.111-alpha #1955

Description

@sghctoma

Bug description

Trying to build a project that has a class with an array of arrays member fails when the >=v3.0.111-alpha NuGet package is used. v3.0.54-alpha is the last working v3 version. What's strange to me, is that I tried to bisect the commit where this broke, checked out the v3.0.134-beta tag, added it as a ProjectReference, and the build succeeded. So this happens only with the NuGet package, and I have no idea how to dig further. To summarize what I observerd:

  • v3.0.54-alpha is the last version not affected by this.
  • v2.x.x versions are not affected.
  • The build error happens only with the NuGet package.
  • I have observed the build failure only with array of arrays (simple ([]), and multidimensional ([,]) arrays work as expected).

Repro steps

The following code can be used to reproduce the build failure:

Program.cs:

using MessagePack;

A a = new();

[MessagePackObject]
public class A
{
    public int[][]? M { get; set; }
};

MessagePackTest.csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <!--  Build fails with the NuGet package -->
    <PackageReference Include="MessagePack" Version="3.0.134-beta" />

    <!--  Build succeeds with referencing the checked-out 3.0.134-beta tag -->
    <!-- <ProjectReference Include="..\MessagePack-CSharp\src\MessagePack\MessagePack.csproj" /> -->
  </ItemGroup>
</Project>

Expected behavior

dotnet build succeeds.

Actual behavior

dotnet build fails with the following error message:

/home/sghctoma/projects/misc/dotnet/MessagePackTest/obj/Debug/net8.0/MessagePack.SourceGenerator/MessagePack.SourceGenerator.MessagePackGenerator/MessagePack.GeneratedMessagePackResolver.g.cs(47,21): error CS1001: Identifier expected [/home/sghctoma/projects/misc/dotnet/MessagePackTest/MessagePackTest.csproj]

The file the message refers to does not even exist. In fact, there's no obj/Debug/net8.0/MessagePack.SourceGenerator folder.

  • Version used: v3.0.111-alpha, v3.0.129-beta, v3.0.134-beta
  • Runtime: .NET Core 8.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions