jburzynski/TypeGen

GenerationSpecs is slow

Closed this issue · 2 comments

Is there a way to specify the full namespace, type and assembly in order to speed up the generation when using a GenerationSpec file?

My current tgconfig.json:

{
  "generationSpecs": ["MyGenerationSpec"],
  "assemblies": ["bin/net7.0/MyAssembly.dll"]
}

Right now it takes 10 minutes to run dotnet-typegen generate on a build agent. Not sure if it uses reflection to go through all assemblies to find MyGenerationSpec, but it seems very inefficient. Ideally it would be possible to specify the full namespace to avoid this: Foo.Bar.MyGenerationSpec, MyAssembly.

Currently it's also possible to specify the full name, so "generationSpecs": ["Foo.Bar.MyGenerationSpec"], should work, but I think it will still search all assemblies - but it will definitely be faster than just ["MyGenerationSpec"].

Apart from this, it's possible to specify the assembly's path and the type name, so something like this should also work: "generationSpecs": ["assembly/path/assembly.dll:Foo.Bar.MyGenerationSpec"],.

I think it's not possible to just specify the assembly name (without the filepath), like Foo.Bar.MyGenerationSpec, MyAssembly.

The docs currently say this:

(*) The rules for specifying class names are as follows:

  • Class names can be specified as a name or a fully qualified name.
  • If only the name of a class is specified, the class will first be searched in the assemblies specified in assemblies (or the project’s assembly if no assemblies are specified) and then (if not found) in TypeGen.Core.
  • To read a class from a specific assembly, path can be defined in the following format: assembly/path/assembly.dll:ClassName, where assembly path is relative to the project’s folder.

Thanks! That definitely helped with the speed.