private static void AddBaseType(CodeFixContext context, ClassDeclarationSyntax classDeclaration, TypeSyntax viewModelBaseType, DocumentEditor editor) { if (classDeclaration.BaseList != null && classDeclaration.BaseList.Types.TryFirst( x => (x.Type as IdentifierNameSyntax)?.Identifier.ValueText.Contains("INotifyPropertyChanged") == true, out var baseType) && context.Diagnostics.Any(IsINotifyPropertyChangedMissing)) { editor.ReplaceNode(baseType, SyntaxFactory.SimpleBaseType(viewModelBaseType)); } else { editor.AddBaseType(classDeclaration, viewModelBaseType); } }