@@ -41,9 +41,9 @@ public sealed class DefaultModelTypeBuilder : IModelTypeBuilder
4141 private readonly bool adHoc ;
4242 private readonly bool excludeAdHocModels ;
4343 private DefaultModelTypeBuilder ? adHocBuilder ;
44- private ConcurrentDictionary < ApiVersion , ModuleBuilder > ? modules ;
45- private ConcurrentDictionary < ApiVersion , IDictionary < EdmTypeKey , Type > > ? generatedEdmTypesPerVersion ;
46- private ConcurrentDictionary < ApiVersion , ConcurrentDictionary < EdmTypeKey , Type > > ? generatedActionParamsPerVersion ;
44+ private ConcurrentDictionary < EdmModelKey , ModuleBuilder > ? modules ;
45+ private ConcurrentDictionary < EdmModelKey , IDictionary < EdmTypeKey , Type > > ? generatedEdmTypesPerVersion ;
46+ private ConcurrentDictionary < EdmModelKey , ConcurrentDictionary < EdmTypeKey , Type > > ? generatedActionParamsPerVersion ;
4747
4848 private DefaultModelTypeBuilder ( bool excludeAdHocModels , bool adHoc )
4949 {
@@ -96,7 +96,7 @@ public Type NewStructuredType( IEdmModel model, IEdmStructuredType structuredTyp
9696
9797 generatedEdmTypesPerVersion ??= new ( ) ;
9898
99- var edmTypes = generatedEdmTypesPerVersion . GetOrAdd ( apiVersion , key => GenerateTypesForEdmModel ( model , key ) ) ;
99+ var edmTypes = generatedEdmTypesPerVersion . GetOrAdd ( new ( model , apiVersion ) , key => GenerateTypesForEdmModel ( model , key . ApiVersion ) ) ;
100100
101101 return edmTypes [ new ( structuredType , apiVersion ) ] ;
102102 }
@@ -132,15 +132,15 @@ public Type NewActionParameters( IEdmModel model, IEdmAction action, string cont
132132
133133 generatedActionParamsPerVersion ??= new ( ) ;
134134
135- var paramTypes = generatedActionParamsPerVersion . GetOrAdd ( apiVersion , _ => new ( ) ) ;
135+ var paramTypes = generatedActionParamsPerVersion . GetOrAdd ( new ( model , apiVersion ) , _ => new ( ) ) ;
136136 var fullTypeName = $ "{ controllerName } .{ action . Namespace } .{ controllerName } { action . Name } Parameters";
137137 var key = new EdmTypeKey ( fullTypeName , apiVersion ) ;
138138 var type = paramTypes . GetOrAdd ( key , _ =>
139139 {
140140 var context = new TypeSubstitutionContext ( model , this , apiVersion ) ;
141141 var properties = action . Parameters . Where ( p => p . Name != "bindingParameter" ) . Select ( p => new ClassProperty ( p , context ) ) ;
142142 var signature = new ClassSignature ( fullTypeName , properties , apiVersion ) ;
143- var moduleBuilder = ( modules ??= new ( ) ) . GetOrAdd ( apiVersion , CreateModuleForApiVersion ) ;
143+ var moduleBuilder = ( modules ??= new ( ) ) . GetOrAdd ( new ( model , apiVersion ) , CreateModuleForApiVersion ) ;
144144
145145 return CreateTypeFromSignature ( moduleBuilder , signature ) ;
146146 } ) ;
@@ -150,7 +150,7 @@ public Type NewActionParameters( IEdmModel model, IEdmAction action, string cont
150150
151151 private IDictionary < EdmTypeKey , Type > GenerateTypesForEdmModel ( IEdmModel model , ApiVersion apiVersion )
152152 {
153- ModuleBuilder NewModuleBuilder ( ) => ( modules ??= new ( ) ) . GetOrAdd ( apiVersion , CreateModuleForApiVersion ) ;
153+ ModuleBuilder NewModuleBuilder ( ) => ( modules ??= new ( ) ) . GetOrAdd ( new ( model , apiVersion ) , CreateModuleForApiVersion ) ;
154154
155155 var context = new BuilderContext ( model , apiVersion , NewModuleBuilder ) ;
156156
@@ -336,7 +336,7 @@ private static Type ResolveType(
336336 return type ;
337337 }
338338
339- var signature = new ClassSignature ( clrType , properties , apiVersion ) ;
339+ var signature = new ClassSignature ( typeKey . FullName , clrType , properties , apiVersion ) ;
340340
341341 if ( hasUnfinishedTypes )
342342 {
@@ -518,9 +518,9 @@ private static AssemblyName NewAssemblyName( ApiVersion apiVersion, bool adHoc )
518518 }
519519
520520 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
521- private ModuleBuilder CreateModuleForApiVersion ( ApiVersion apiVersion )
521+ private ModuleBuilder CreateModuleForApiVersion ( EdmModelKey key )
522522 {
523- var assemblyName = NewAssemblyName ( apiVersion , adHoc ) ;
523+ var assemblyName = NewAssemblyName ( key . ApiVersion , adHoc ) ;
524524#if NETFRAMEWORK
525525 var assemblyBuilder = AppDomain . CurrentDomain . DefineDynamicAssembly ( assemblyName , Run ) ;
526526#else
0 commit comments