smdn / Smdn.Reflection.ReverseGenerating

.NET libraries and tools to reverse-generate C# code from type and member information using reflection
https://smdn.jp/works/libs/Smdn.Reflection.ReverseGenerating/
MIT License
1 stars 0 forks source link

Calling CSharpFormatter.FormatTypeName in parallel causes ArgumentException #20

Closed smdn closed 1 year ago

smdn commented 2 years ago

NullabilityInfoContext.Create does not support parallel call.

Unhandled exception. System.AggregateException: One or more errors occurred. (An item with the same key has already been added. Key: System.Net.WebRequest)
 ---> System.ArgumentException: An item with the same key has already been added. Key: System.Net.WebRequest
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Reflection.NullabilityInfoContext.GetNullableContext(MemberInfo memberInfo)
   at System.Reflection.NullabilityInfoContext.GetNullabilityInfo(MemberInfo memberInfo, Type type, IList`1 customAttributes, Int32 index)
   at System.Reflection.NullabilityInfoContext.Create(ParameterInfo parameterInfo)
   at Smdn.Reflection.ReverseGenerating.CSharpFormatter.FormatTypeName(ParameterInfo p, NullabilityInfoContext nullabilityInfoContext, Boolean typeWithNamespace, Boolean withDeclaringTypeName, Boolean translateLanguagePrimitiveType) in /_/src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeName.cs:line 142