@@ -41,9 +41,9 @@ public sealed class DefaultModelTypeBuilder : IModelTypeBuilder
41
41
private readonly bool adHoc ;
42
42
private readonly bool excludeAdHocModels ;
43
43
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 ;
47
47
48
48
private DefaultModelTypeBuilder ( bool excludeAdHocModels , bool adHoc )
49
49
{
@@ -96,7 +96,7 @@ public Type NewStructuredType( IEdmModel model, IEdmStructuredType structuredTyp
96
96
97
97
generatedEdmTypesPerVersion ??= new ( ) ;
98
98
99
- var edmTypes = generatedEdmTypesPerVersion . GetOrAdd ( apiVersion , key => GenerateTypesForEdmModel ( model , key ) ) ;
99
+ var edmTypes = generatedEdmTypesPerVersion . GetOrAdd ( new ( model , apiVersion ) , key => GenerateTypesForEdmModel ( model , key . ApiVersion ) ) ;
100
100
101
101
return edmTypes [ new ( structuredType , apiVersion ) ] ;
102
102
}
@@ -132,15 +132,15 @@ public Type NewActionParameters( IEdmModel model, IEdmAction action, string cont
132
132
133
133
generatedActionParamsPerVersion ??= new ( ) ;
134
134
135
- var paramTypes = generatedActionParamsPerVersion . GetOrAdd ( apiVersion , _ => new ( ) ) ;
135
+ var paramTypes = generatedActionParamsPerVersion . GetOrAdd ( new ( model , apiVersion ) , _ => new ( ) ) ;
136
136
var fullTypeName = $ "{ controllerName } .{ action . Namespace } .{ controllerName } { action . Name } Parameters";
137
137
var key = new EdmTypeKey ( fullTypeName , apiVersion ) ;
138
138
var type = paramTypes . GetOrAdd ( key , _ =>
139
139
{
140
140
var context = new TypeSubstitutionContext ( model , this , apiVersion ) ;
141
141
var properties = action . Parameters . Where ( p => p . Name != "bindingParameter" ) . Select ( p => new ClassProperty ( p , context ) ) ;
142
142
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 ) ;
144
144
145
145
return CreateTypeFromSignature ( moduleBuilder , signature ) ;
146
146
} ) ;
@@ -150,7 +150,7 @@ public Type NewActionParameters( IEdmModel model, IEdmAction action, string cont
150
150
151
151
private IDictionary < EdmTypeKey , Type > GenerateTypesForEdmModel ( IEdmModel model , ApiVersion apiVersion )
152
152
{
153
- ModuleBuilder NewModuleBuilder ( ) => ( modules ??= new ( ) ) . GetOrAdd ( apiVersion , CreateModuleForApiVersion ) ;
153
+ ModuleBuilder NewModuleBuilder ( ) => ( modules ??= new ( ) ) . GetOrAdd ( new ( model , apiVersion ) , CreateModuleForApiVersion ) ;
154
154
155
155
var context = new BuilderContext ( model , apiVersion , NewModuleBuilder ) ;
156
156
@@ -336,7 +336,7 @@ private static Type ResolveType(
336
336
return type ;
337
337
}
338
338
339
- var signature = new ClassSignature ( clrType , properties , apiVersion ) ;
339
+ var signature = new ClassSignature ( typeKey . FullName , clrType , properties , apiVersion ) ;
340
340
341
341
if ( hasUnfinishedTypes )
342
342
{
@@ -518,9 +518,9 @@ private static AssemblyName NewAssemblyName( ApiVersion apiVersion, bool adHoc )
518
518
}
519
519
520
520
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
521
- private ModuleBuilder CreateModuleForApiVersion ( ApiVersion apiVersion )
521
+ private ModuleBuilder CreateModuleForApiVersion ( EdmModelKey key )
522
522
{
523
- var assemblyName = NewAssemblyName ( apiVersion , adHoc ) ;
523
+ var assemblyName = NewAssemblyName ( key . ApiVersion , adHoc ) ;
524
524
#if NETFRAMEWORK
525
525
var assemblyBuilder = AppDomain . CurrentDomain . DefineDynamicAssembly ( assemblyName , Run ) ;
526
526
#else
0 commit comments