Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpc - add externalIgnoreTypeNames feature #1019

Merged
merged 2 commits into from
Sep 2, 2020
Merged

mpc - add externalIgnoreTypeNames feature #1019

merged 2 commits into from
Sep 2, 2020

Conversation

neuecc
Copy link
Member

@neuecc neuecc commented Aug 27, 2020

For example Cysharp/Ulid#12
when third-party library provides external resolver, mpc should ignore there types.

I've added string[]? externalIgnoreTypeNames parameter that can set ignore type from mpc.

@neuecc neuecc merged commit 683e815 into v2.2 Sep 2, 2020
@AArnott AArnott deleted the improve-mpc branch September 10, 2020 16:55
@NoxMortem
Copy link
Contributor

@neuecc, @AArnott how is this used?

dotnet tool restore
Paket-ID                   Version      Befehle         Manifest
---------------------------------------------------------------------------------------------------------------------
messagepack.generator      2.1.165      dotnet-mpc      ...

Does print

Project Compilation Start:.

but I do not see any external ignores listed from

 externalIgnoreTypeNames, x => Console.WriteLine(x));

and still get

PS E:\repositories\visionary\Visionary> dotnet mpc -i . -o "Assets\Scripts\Frameworks\MessagePack" -ei "global::System.Ulid"
Project Compilation Start:.
Project Compilation Complete:00:00:32.6588678
Method Collect Start
Fail in console app running on MessagepackCompiler.RunAsync
MessagePackCompiler.CodeAnalysis.MessagePackGeneratorResolveFailedException: Serialization Object must mark MessagePackObjectAttribute. type: global::System.Ulid
  at MessagePackCompiler.CodeAnalysis.TypeCollector.GetObjectInfo(INamedTypeSymbol type) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 610
  at MessagePackCompiler.CodeAnalysis.TypeCollector.CollectObject(INamedTypeSymbol type) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 604
  at MessagePackCompiler.CodeAnalysis.TypeCollector.CollectCore(ITypeSymbol typeSymbol) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 392
  at MessagePackCompiler.CodeAnalysis.TypeCollector.CollectGeneric(INamedTypeSymbol type) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 522
  at MessagePackCompiler.CodeAnalysis.TypeCollector.CollectCore(ITypeSymbol typeSymbol) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 371
  at MessagePackCompiler.CodeAnalysis.TypeCollector.GetObjectInfo(INamedTypeSymbol type) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 784
  at MessagePackCompiler.CodeAnalysis.TypeCollector.CollectObject(INamedTypeSymbol type) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 604
  at MessagePackCompiler.CodeAnalysis.TypeCollector.CollectCore(ITypeSymbol typeSymbol) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 392
  at MessagePackCompiler.CodeAnalysis.TypeCollector.Collect() in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 323
  at MessagePackCompiler.CodeGenerator.GenerateFileAsync(String input, String output, String conditionalSymbol, String resolverName, String namespace, Boolean useMapMode, String multipleIfDirectiveOutputSymbols) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeGenerator.cs:line 58
  at MessagePack.Generator.MessagepackCompiler.RunAsync(String input, String output, String conditionalSymbol, String resolverName, String namespace, Boolean useMapMode, String multipleIfDirectiveOutputSymbols) in D:\a\1\s\src\MessagePack.Generator\MessagepackCompiler.cs:line 30
  at ConsoleAppFramework.ConsoleAppEngine.RunCore(ConsoleAppContext ctx, Type type, MethodInfo methodInfo, String[] args, Int32 argsOffset)

@AArnott
Copy link
Collaborator

AArnott commented Jul 1, 2021

@NoxMortem It looks like you're using 2.1, but this change went into 2.2. Can you upgrade your tool?

@NoxMortem
Copy link
Contributor

NoxMortem commented Apr 8, 2022

@AArnott , @neuecc

Edit: Sorry. Mea Culpa. I can confirm it is working now.

Confirmed with:

  • MessagePack.Unity.2.3.85.unitypackage
  • com.cysharp.ulid with version 1.2.6
  • dotnet mpc --version 2.3.85+b676113676

I might have forgotten to specify the type correctly. This is working.

dotnet mpc -ei "System.Ulid" -i . -o "Assets\Scripts\Frameworks\MessagePack"

And it works. It is important to use System.Ulid and not global::System.Ulid from the error message - which is not recognized.

Project Compilation Start:CodeGenTemp
Project Compilation Complete:00:00:27.1301017
Method Collect Start
Method Collect Complete:00:00:00.0374464
Output Generation Start
[Out]Assets\Scripts\Frameworks\MessagePack\MessagePack_Formatters_Application_OrderedPointCloud_Cache_RawDataRegistryMpkFormatter.cs
[Out]Assets\Scripts\Frameworks\MessagePack\MessagePack_Formatters_Application_OrderedPointCloud_Files_MessagePacks_AabbMpkFormatter.cs
[Out]Assets\Scripts\Frameworks\MessagePack\MessagePack_Formatters_Application_OrderedPointCloud_Files_MessagePacks_DotsOpcSurfaceMpkFormatter.cs
[Out]Assets\Scripts\Frameworks\MessagePack\MessagePack_Formatters_Application_OrderedPointCloud_Files_MessagePacks_DotsPatchHierarchyMpkFormatter.cs
[Out]Assets\Scripts\Frameworks\MessagePack\MessagePack_Formatters_Application_OrderedPointCloud_Files_MessagePacks_IndicesOfLevelFormatter.cs
[Out]Assets\Scripts\Frameworks\MessagePack\MessagePack_Formatters_Application_OrderedPointCloud_Files_MessagePacks_MeshMpkFormatter.cs
[Out]Assets\Scripts\Frameworks\MessagePack\MessagePack_Formatters_Application_OrderedPointCloud_Files_MessagePacks_OpcSurfaceMpkFormatter.cs
[Out]Assets\Scripts\Frameworks\MessagePack\MessagePack_Formatters_Application_OrderedPointCloud_Files_MessagePacks_PatchHierarchyMpkFormatter.cs
[Out]Assets\Scripts\Frameworks\MessagePack\MessagePack_Formatters_Application_OrderedPointCloud_Files_MessagePacks_SubPatchMappingFormatter.cs
[Out]Assets\Scripts\Frameworks\MessagePack\MessagePack_Formatters_Application_OrderedPointCloud_Files_MessagePacks_TextureMpkFormatter.cs
[Out]Assets\Scripts\Frameworks\MessagePack\MessagePack_Formatters_Application_Project_Files_Mpk_ProjectCacheRegistryMpkFormatter.cs
[Out]Assets\Scripts\Frameworks\MessagePack\MessagePack_Formatters_Application_Project_Files_Mpk_ProjectFileMpkFormatter.cs
[Out]Assets\Scripts\Frameworks\MessagePack\MessagePack_Formatters_Examples__15_StreamLargeScenePicking_DirectoryTreeCacheFormatter.cs
[Out]Assets\Scripts\Frameworks\MessagePack\MessagePack_Resolvers_GeneratedResolver.cs

@AArnott
Copy link
Collaborator

AArnott commented Jun 7, 2022

@NoxMortem passing the path to an msbuild project instead of the path to a directory will allow mpc to be much more tolerant to any c# syntax and still generate valid C# files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants