jburzynski / TypeGen

Single-class-per-file C# to TypeScript generator
MIT License
197 stars 56 forks source link

Error after update from 4.0.1 to 4.1.0 #168

Open jmalczak opened 1 year ago

jmalczak commented 1 year ago

Hi

After update from 4.0.1 we have some issues with typescript generation. We use following configuration:

` var generationOptions = new GeneratorOptions { UseDefaultExport = true, FileNameConverters = new TypeNameConverterCollection(new TypesNameConverter()), };

        var tsGenerator = new Generator(generationOptions);

            await tsGenerator.GenerateAsync(new List<GenerationSpec>
            {

// even simple type that doesn't inherit from anything }); `

Before update, everything works fine and files are generated. After update I had to install manually since it was throwing missing assembly when running generate. After adding this assembly there is next error regarding missing assembly:

` System.ApplicationException: TS types generation failed. Make sure all .NET types exported TS are inside scanned assemblies. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Mvc.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

File name: 'Microsoft.AspNetCore.Mvc.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' at System.ModuleHandle.ResolveType(QCallModule module, Int32 typeToken, IntPtr typeInstArgs, Int32 typeInstCount, IntPtr methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) at System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctorWithParameters, Boolean& isVarArg) at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder1 derivedAttributes) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType) at Namotion.Reflection.NullableFlagsSource.GetNullableFlags[T](T provider) at Namotion.Reflection.NullableFlagsSource..ctor(Type type, Assembly assembly) at Namotion.Reflection.NullableFlagsSource.Create(Type type, Assembly assembly) at Namotion.Reflection.ContextualPropertyInfo..ctor(PropertyInfo propertyInfo, Int32& nullableFlagsIndex, Byte[] nullableFlags) at Namotion.Reflection.ContextualTypeExtensions.<>c__DisplayClass10_0.<ToContextualProperty>b__0(CacheKey k) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Namotion.Reflection.ContextualTypeExtensions.ToContextualProperty(PropertyInfo propertyInfo) at Namotion.Reflection.ContextualTypeExtensions.ToContextualAccessor(MemberInfo memberInfo) at TypeGen.Core.Extensions.TypeExtensions.IsNullable(MemberInfo memberInfo) at TypeGen.Core.Generator.Services.TypeService.GetTypeUnions(MemberInfo memberInfo) at TypeGen.Core.Generator.Generator.GetClassPropertyText(MemberInfo memberInfo) at TypeGen.Core.Generator.Generator.<GetClassPropertiesText>b__45_0(String current, MemberInfo memberInfo) at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable1 source, TAccumulate seed, Func3 func) at TypeGen.Core.Generator.Generator.GetClassPropertiesText(Type type) at TypeGen.Core.Generator.Generator.GenerateClassOrInterface(Type type, ExportTsClassAttribute classAttribute, ExportTsInterfaceAttribute interfaceAttribute) at TypeGen.Core.Generator.Generator.GenerateClass(Type type, ExportTsClassAttribute classAttribute) at TypeGen.Core.Generator.Generator.GenerateNotMarked(Type type, String outputDirectory) at TypeGen.Core.Generator.Generator.GenerateTypeDependencies(Type type, String outputDir) at TypeGen.Core.Generator.Generator.GenerateClassOrInterface(Type type, ExportTsClassAttribute classAttribute, ExportTsInterfaceAttribute interfaceAttribute) at TypeGen.Core.Generator.Generator.GenerateClass(Type type, ExportTsClassAttribute classAttribute) at TypeGen.Core.Generator.Generator.GenerateNotMarked(Type type, String outputDirectory) at TypeGen.Core.Generator.Generator.GenerateTypeDependencies(Type type, String outputDir) at TypeGen.Core.Generator.Generator.GenerateClassOrInterface(Type type, ExportTsClassAttribute classAttribute, ExportTsInterfaceAttribute interfaceAttribute) at TypeGen.Core.Generator.Generator.GenerateClass(Type type, ExportTsClassAttribute classAttribute) at TypeGen.Core.Generator.Generator.GenerateType(Type type) at TypeGen.Core.Generator.Generator.GenerateTypeInit(Type type) at TypeGen.Core.Generator.Generator.Generate(IEnumerable1 generationSpecs) at TypeGen.Core.Generator.Generator.<>c__DisplayClass24_0.b__0() at System.Threading.Tasks.Task1.InnerInvoke() at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)

After rollback to 4.0.1 everything works again. Used in console project to generate typescript files for classes from .net 7 (asp.net core assembly).