MessagePack-CSharp / MessagePack-CSharp

Extremely Fast MessagePack Serializer for C#(.NET, .NET Core, Unity, Xamarin). / msgpack.org[C#]
Other
5.57k stars 685 forks source link

Generation of Message Pack fails with .Net 7 #1718

Open mohamed-magdy opened 8 months ago

mohamed-magdy commented 8 months ago

Bug description

when i try to generate the message pack file using the mpc it crashes and gives me the following error message "System.IndexOutOfRangeException: Index was outside the bounds of the array. at MessagePackCompiler.CodeAnalysis.TypeCollector.GetObjectInfo(INamedTypeSymbol type) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 586 at MessagePackCompiler.CodeAnalysis.TypeCollector.CollectObject(INamedTypeSymbol type) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 580 at MessagePackCompiler.CodeAnalysis.TypeCollector.CollectCore(ITypeSymbol typeSymbol) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 381 at MessagePackCompiler.CodeAnalysis.TypeCollector.Collect() in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 301 at MessagePackCompiler.CodeGenerator.GenerateFileAsync(Compilation compilation, String output, String resolverName, String namespace, Boolean useMapMode, String multipleIfDirectiveOutputSymbols, String[] externalIgnoreTypeNames) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeGenerator.cs:line 64 at MessagePack.Generator.MessagepackCompiler.RunAsync(String input, String output, String conditionalSymbol, String resolverName, String namespace, Boolean useMapMode, String multipleIfDirectiveOutputSymbols, String[] externalIgnoreTypeNames) in D:\a\1\s\src\MessagePack.Generator\MessagepackCompiler.cs:line 65 at ConsoleAppFramework.ConsoleAppEngine.RunCore(ConsoleAppContext ctx, Type type, MethodInfo methodInfo, String[] args, Int32 argsOffset)".

Repro steps

Code to reproduce the behavior.

Expected behavior

A clear and concise description of what you expected to happen.

Actual behavior

What happened instead of what you expected.

Additional context

Add any other context about the problem here.

AArnott commented 8 months ago

Can you try using the source generator in the 2.6 prerelease? (docs in the README of the dev branch) mpc is deprecated.

Sean4572435243 commented 7 months ago

I looked at the readme changes here but I don't have a clue how to proceed with 2.6.100 without using mpc..Not using mpc just results in the expected "ClassLibrary1.Class1 is not registered in resolver" error. What are the steps?

AArnott commented 7 months ago

Those readme changes are too recent, perhaps. And incomplete, since you're only looking at a single commit. The readme at the tip of the develop branch is newer than the last prerelease to nuget.org at this point, so it'll be misleading unless you're using the latest CI build of the library from the develop branch.

Here's a precise link to exactly the readme content that is appropriate for the 2.6.100 prerelease on nuget.org. Hopefully that'll work for you.