@@ -191,16 +191,33 @@ public virtual string Lambda(IReadOnlyList<string> properties, string? lambdaIde
191
191
/// any release. You should only use it directly in your code with extreme caution and knowing that
192
192
/// doing so can result in application failures when updating to a new Entity Framework Core release.
193
193
/// </summary>
194
- public virtual string Reference ( Type type )
195
- => Reference ( type , useFullName : false ) ;
196
-
197
- private string Reference ( Type type , bool useFullName )
194
+ public virtual string Reference ( Type type , bool ? fullName = null )
198
195
{
199
196
Check . NotNull ( type , nameof ( type ) ) ;
200
197
201
- return type . DisplayName ( fullName : useFullName , compilable : true ) ;
198
+ fullName ??= type . IsNested ? ShouldUseFullName ( type . DeclaringType ! ) : ShouldUseFullName ( type ) ;
199
+
200
+ return type . DisplayName ( fullName . Value , compilable : true ) ;
202
201
}
203
202
203
+ /// <summary>
204
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
205
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
206
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
207
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
208
+ /// </summary>
209
+ public virtual bool ShouldUseFullName ( Type type )
210
+ => ShouldUseFullName ( type . Name ) ;
211
+
212
+ /// <summary>
213
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
214
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
215
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
216
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
217
+ /// </summary>
218
+ public virtual bool ShouldUseFullName ( string shortTypeName )
219
+ => false ;
220
+
204
221
/// <summary>
205
222
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
206
223
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
@@ -536,8 +553,8 @@ public virtual string Literal(BigInteger value)
536
553
/// any release. You should only use it directly in your code with extreme caution and knowing that
537
554
/// doing so can result in application failures when updating to a new Entity Framework Core release.
538
555
/// </summary>
539
- public virtual string Literal ( Type value )
540
- => $ "typeof({ Reference ( value ) } )";
556
+ public virtual string Literal ( Type value , bool ? useFullName = null )
557
+ => $ "typeof({ Reference ( value , useFullName ) } )";
541
558
542
559
/// <summary>
543
560
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -845,14 +862,14 @@ private bool HandleExpression(Expression expression, StringBuilder builder, bool
845
862
case ExpressionType . Convert :
846
863
builder
847
864
. Append ( '(' )
848
- . Append ( Reference ( expression . Type , useFullName : true ) )
865
+ . Append ( Reference ( expression . Type , fullName : true ) )
849
866
. Append ( ')' ) ;
850
867
851
868
return HandleExpression ( ( ( UnaryExpression ) expression ) . Operand , builder ) ;
852
869
case ExpressionType . New :
853
870
builder
854
871
. Append ( "new " )
855
- . Append ( Reference ( expression . Type , useFullName : true ) ) ;
872
+ . Append ( Reference ( expression . Type , fullName : true ) ) ;
856
873
857
874
return HandleArguments ( ( ( NewExpression ) expression ) . Arguments , builder ) ;
858
875
case ExpressionType . Call :
@@ -861,7 +878,7 @@ private bool HandleExpression(Expression expression, StringBuilder builder, bool
861
878
if ( callExpression . Method . IsStatic )
862
879
{
863
880
builder
864
- . Append ( Reference ( callExpression . Method . DeclaringType ! , useFullName : true ) ) ;
881
+ . Append ( Reference ( callExpression . Method . DeclaringType ! , fullName : true ) ) ;
865
882
}
866
883
else
867
884
{
@@ -895,7 +912,7 @@ private bool HandleExpression(Expression expression, StringBuilder builder, bool
895
912
if ( memberExpression . Expression == null )
896
913
{
897
914
builder
898
- . Append ( Reference ( memberExpression . Member . DeclaringType ! , useFullName : true ) ) ;
915
+ . Append ( Reference ( memberExpression . Member . DeclaringType ! , fullName : true ) ) ;
899
916
}
900
917
else
901
918
{
0 commit comments