@@ -65,7 +65,8 @@ private void ValidateRenameFieldHints(IEnumerable<RenameFieldHint> hints)
6565 var targetType = currentModel . Types . SingleOrDefault ( type => type . UnderlyingType == targetTypeName ) ;
6666 if ( targetType == null )
6767 throw TypeNotFound ( targetTypeName ) ;
68- var sourceType = reverseTypeMapping [ targetType ] ;
68+ if ( ! reverseTypeMapping . TryGetValue ( targetType , out var sourceType ) )
69+ throw TypeNotFoundInStorageModel ( targetTypeName , hint . OldFieldName ) ;
6970 var sourceTypeName = sourceType . UnderlyingType ;
7071 if ( sourceType . GetField ( hint . OldFieldName ) == null )
7172 throw FieldNotFound ( sourceTypeName , hint . OldFieldName ) ;
@@ -145,20 +146,17 @@ private void ValidateRemoveTypeHints(IEnumerable<RemoveTypeHint> hints)
145146 }
146147 }
147148
148- private static InvalidOperationException TypeNotFound ( string name )
149- {
150- return new InvalidOperationException ( string . Format ( Strings . ExTypeXIsNotFound , name ) ) ;
151- }
149+ private static InvalidOperationException TypeNotFound ( string name ) =>
150+ new InvalidOperationException ( string . Format ( Strings . ExTypeXIsNotFound , name ) ) ;
152151
153- private static InvalidOperationException FieldNotFound ( string typeName , string fieldName )
154- {
155- return new InvalidOperationException ( string . Format ( Strings . ExFieldXYIsNotFound , typeName , fieldName ) ) ;
156- }
152+ private static InvalidOperationException TypeNotFoundInStorageModel ( string typeName , string oldFieldName ) =>
153+ new InvalidOperationException ( string . Format ( Strings . ExTypeXWhichContainsRenamingFieldYDoesntExistInStorageModel , typeName , oldFieldName ) ) ;
157154
158- private static InvalidOperationException HintConflict ( UpgradeHint hintOne , UpgradeHint hintTwo )
159- {
160- return new InvalidOperationException ( string . Format ( Strings . ExHintXIsConflictingWithHintY , hintOne , hintTwo ) ) ;
161- }
155+ private static InvalidOperationException FieldNotFound ( string typeName , string fieldName ) =>
156+ new InvalidOperationException ( string . Format ( Strings . ExFieldXYIsNotFound , typeName , fieldName ) ) ;
157+
158+ private static InvalidOperationException HintConflict ( UpgradeHint hintOne , UpgradeHint hintTwo ) =>
159+ new InvalidOperationException ( string . Format ( Strings . ExHintXIsConflictingWithHintY , hintOne , hintTwo ) ) ;
162160
163161 public UpgradeHintValidator ( StoredDomainModel currentModel , StoredDomainModel extractedModel , Dictionary < StoredTypeInfo , StoredTypeInfo > typeMapping , Dictionary < StoredTypeInfo , StoredTypeInfo > reverseTypeMapping )
164162 {
0 commit comments