@@ -64,7 +64,7 @@ public virtual void Generate(string modelBuilderName, IModel model, IndentedStri
6464 annotations [ CoreAnnotationNames . ProductVersion ] = new Annotation ( CoreAnnotationNames . ProductVersion , productVersion ) ;
6565 }
6666
67- GenerateRemainingAnnotations ( modelBuilderName , model , stringBuilder , annotations , inChainedCall : false , leadingNewline : false ) ;
67+ GenerateAnnotations ( modelBuilderName , model , stringBuilder , annotations , inChainedCall : false , leadingNewline : false ) ;
6868
6969 foreach ( var sequence in model . GetSequences ( ) )
7070 {
@@ -479,6 +479,7 @@ protected virtual void GenerateProperty(
479479 . AppendLine ( )
480480 . Append ( propertyBuilderName ) ;
481481
482+ // Note that GenerateAnnotations below does the corresponding decrement
482483 stringBuilder . IncrementIndent ( ) ;
483484
484485 if ( property . IsConcurrencyToken )
@@ -550,7 +551,7 @@ protected virtual void GeneratePropertyAnnotations(
550551 GenerateFluentApiForDefaultValue ( property , stringBuilder ) ;
551552 annotations . Remove ( RelationalAnnotationNames . DefaultValue ) ;
552553
553- GenerateRemainingAnnotations ( propertyBuilderName , property , stringBuilder , annotations , inChainedCall : true ) ;
554+ GenerateAnnotations ( propertyBuilderName , property , stringBuilder , annotations , inChainedCall : true ) ;
554555 }
555556
556557 private ValueConverter ? FindValueConverter ( IProperty property )
@@ -616,6 +617,7 @@ protected virtual void GenerateKey(
616617 . Append ( string . Join ( ", " , key . Properties . Select ( p => Code . Literal ( p . Name ) ) ) )
617618 . Append ( ")" ) ;
618619
620+ // Note that GenerateAnnotations below does the corresponding decrement
619621 stringBuilder . IncrementIndent ( ) ;
620622
621623 GenerateKeyAnnotations ( entityTypeBuilderName , key , stringBuilder ) ;
@@ -637,7 +639,7 @@ protected virtual void GenerateKeyAnnotations(string entityTypeBuilderName, IKey
637639 . FilterIgnoredAnnotations ( key . GetAnnotations ( ) )
638640 . ToDictionary ( a => a . Name , a => a ) ;
639641
640- GenerateRemainingAnnotations ( entityTypeBuilderName , key , stringBuilder , annotations , inChainedCall : true ) ;
642+ GenerateAnnotations ( entityTypeBuilderName , key , stringBuilder , annotations , inChainedCall : true ) ;
641643 }
642644
643645 /// <summary>
@@ -690,6 +692,7 @@ protected virtual void GenerateIndex(
690692 . AppendLine ( )
691693 . Append ( indexBuilderName ) ;
692694
695+ // Note that GenerateAnnotations below does the corresponding decrement
693696 stringBuilder . IncrementIndent ( ) ;
694697
695698 if ( index . IsUnique )
@@ -721,7 +724,7 @@ protected virtual void GenerateIndexAnnotations(
721724 . FilterIgnoredAnnotations ( index . GetAnnotations ( ) )
722725 . ToDictionary ( a => a . Name , a => a ) ;
723726
724- GenerateRemainingAnnotations ( indexBuilderName , index , stringBuilder , annotations , inChainedCall : true ) ;
727+ GenerateAnnotations ( indexBuilderName , index , stringBuilder , annotations , inChainedCall : true ) ;
725728 }
726729
727730 /// <summary>
@@ -950,7 +953,7 @@ protected virtual void GenerateEntityTypeAnnotations(
950953 stringBuilder . AppendLine ( ";" ) ;
951954 }
952955
953- GenerateRemainingAnnotations ( entityTypeBuilderName , entityType , stringBuilder , annotations , inChainedCall : false ) ;
956+ GenerateAnnotations ( entityTypeBuilderName , entityType , stringBuilder , annotations , inChainedCall : false ) ;
954957 }
955958
956959 /// <summary>
@@ -1078,6 +1081,7 @@ protected virtual void GenerateForeignKey(
10781081 . Append ( ")" )
10791082 . AppendLine ( ) ;
10801083
1084+ // Note that GenerateAnnotations below does the corresponding decrement
10811085 stringBuilder . IncrementIndent ( ) ;
10821086
10831087 if ( foreignKey . IsUnique
@@ -1184,7 +1188,7 @@ protected virtual void GenerateForeignKeyAnnotations(
11841188 . FilterIgnoredAnnotations ( foreignKey . GetAnnotations ( ) )
11851189 . ToDictionary ( a => a . Name , a => a ) ;
11861190
1187- GenerateRemainingAnnotations ( entityTypeBuilderName , foreignKey , stringBuilder , annotations , inChainedCall : true ) ;
1191+ GenerateAnnotations ( entityTypeBuilderName , foreignKey , stringBuilder , annotations , inChainedCall : true ) ;
11881192 }
11891193
11901194 /// <summary>
@@ -1267,6 +1271,7 @@ protected virtual void GenerateNavigation(
12671271 . Append ( Code . Literal ( navigation . Name ) )
12681272 . Append ( ")" ) ;
12691273
1274+ // Note that GenerateAnnotations below does the corresponding decrement
12701275 stringBuilder . IncrementIndent ( ) ;
12711276
12721277 if ( ! navigation . IsOnDependent
@@ -1300,46 +1305,7 @@ protected virtual void GenerateNavigationAnnotations(
13001305 . FilterIgnoredAnnotations ( navigation . GetAnnotations ( ) )
13011306 . ToDictionary ( a => a . Name , a => a ) ;
13021307
1303- GenerateRemainingAnnotations ( entityTypeBuilderName , navigation , stringBuilder , annotations , inChainedCall : true ) ;
1304- }
1305-
1306- /// <summary>
1307- /// Generates code for annotations.
1308- /// </summary>
1309- /// <param name="annotations"> The annotations. </param>
1310- /// <param name="stringBuilder"> The builder code is added to. </param>
1311- protected virtual void GenerateAnnotations (
1312- IEnumerable < IAnnotation > annotations ,
1313- IndentedStringBuilder stringBuilder )
1314- {
1315- Check . NotNull ( annotations , nameof ( annotations ) ) ;
1316- Check . NotNull ( stringBuilder , nameof ( stringBuilder ) ) ;
1317-
1318- foreach ( var annotation in annotations . OrderBy ( a => a . Name ) )
1319- {
1320- stringBuilder . AppendLine ( ) ;
1321- GenerateAnnotation ( annotation , stringBuilder ) ;
1322- }
1323- }
1324-
1325- /// <summary>
1326- /// Generates code for an annotation which does not have a fluent API call.
1327- /// </summary>
1328- /// <param name="annotation"> The annotation. </param>
1329- /// <param name="stringBuilder"> The builder code is added to. </param>
1330- protected virtual void GenerateAnnotation (
1331- IAnnotation annotation ,
1332- IndentedStringBuilder stringBuilder )
1333- {
1334- Check . NotNull ( annotation , nameof ( annotation ) ) ;
1335- Check . NotNull ( stringBuilder , nameof ( stringBuilder ) ) ;
1336-
1337- stringBuilder
1338- . Append ( ".HasAnnotation(" )
1339- . Append ( Code . Literal ( annotation . Name ) )
1340- . Append ( ", " )
1341- . Append ( Code . UnknownLiteral ( annotation . Value ) )
1342- . Append ( ")" ) ;
1308+ GenerateAnnotations ( entityTypeBuilderName , navigation , stringBuilder , annotations , inChainedCall : true ) ;
13431309 }
13441310
13451311 /// <summary>
@@ -1515,7 +1481,7 @@ private void GenerateFluentApiForDefaultValue(
15151481 . Append ( ")" ) ;
15161482 }
15171483
1518- private void GenerateRemainingAnnotations (
1484+ private void GenerateAnnotations (
15191485 string builderName ,
15201486 IAnnotatable annotatable ,
15211487 IndentedStringBuilder stringBuilder ,
@@ -1547,7 +1513,6 @@ private void GenerateRemainingAnnotations(
15471513 // Append remaining raw annotations which did not get generated as Fluent API calls
15481514 foreach ( var annotation in annotations . Values . OrderBy ( a => a . Name ) )
15491515 {
1550- // var call = new MethodCallCodeFragment("HasAnnotation", annotation.Name, annotation.Value);
15511516 var call = new MethodCallCodeFragment ( _hasAnnotationMethodInfo , annotation . Name , annotation . Value ) ;
15521517 nonQualifiedCalls = nonQualifiedCalls is null ? call : nonQualifiedCalls . Chain ( call ) ;
15531518 }
@@ -1593,12 +1558,6 @@ private void GenerateRemainingAnnotations(
15931558 stringBuilder
15941559 . AppendLines ( Code . Fragment ( typeQualifiedCalls , builderName , typeQualified : true ) , skipFinalNewline : true )
15951560 . AppendLine ( ";" ) ;
1596-
1597- // foreach (var call in typeQualifiedCalls)
1598- // {
1599- // stringBuilder.Append(Code.Fragment(call, builderName, typeQualified: true));
1600- // stringBuilder.AppendLine(";");
1601- // }
16021561 }
16031562 }
16041563 }
0 commit comments