diff --git a/src/Vetuviem.SourceGenerator/Features/ControlBindingModels/AbstractControlBindingModelClassGenerator.cs b/src/Vetuviem.SourceGenerator/Features/ControlBindingModels/AbstractControlBindingModelClassGenerator.cs index 95b0984..474160e 100644 --- a/src/Vetuviem.SourceGenerator/Features/ControlBindingModels/AbstractControlBindingModelClassGenerator.cs +++ b/src/Vetuviem.SourceGenerator/Features/ControlBindingModels/AbstractControlBindingModelClassGenerator.cs @@ -274,9 +274,11 @@ private static IEnumerable GetTypeParameterSeparatedSyntaxL } } - private MemberDeclarationSyntax GetConstructorMethod(INamedTypeSymbol namedTypeSymbol, + private MemberDeclarationSyntax GetConstructorMethod( + INamedTypeSymbol namedTypeSymbol, bool isDerivedType, - bool makeClassesPublic, TypeParameterListSyntax typeParameterList) + bool makeClassesPublic, + TypeParameterListSyntax typeParameterList) { var className = GetClassNameIdentifier(namedTypeSymbol); var body = GetConstructorBody(isDerivedType); @@ -306,16 +308,20 @@ private MemberDeclarationSyntax GetConstructorMethod(INamedTypeSymbol namedTypeS ("viewExpression", "expression representing the control on the view to bind to.") }; + var modifiers = GetConstructorModifiers(makeClassesPublic); + var declaration = SyntaxFactory.ConstructorDeclaration(className) .WithInitializer(initializer) .WithParameterList(parameters) - .AddModifiers(SyntaxFactory.Token(makeClassesPublic ? SyntaxKind.PublicKeyword : SyntaxKind.InternalKeyword)) + .AddModifiers(modifiers) .AddBodyStatements(body.ToArray()) .WithLeadingTrivia(XmlSyntaxFactory.GenerateSummaryComment(summaryText, summaryParameters)); return declaration; } + protected abstract SyntaxToken[] GetConstructorModifiers(bool makeClassesPublic); + private TypeParameterListSyntax GetTypeParameterListSyntax(INamedTypeSymbol namedTypeSymbol) { var sep = GetTypeParameterSyntaxes(); diff --git a/src/Vetuviem.SourceGenerator/Features/ControlBindingModels/ControlBoundControlBindingModelClassGenerator.cs b/src/Vetuviem.SourceGenerator/Features/ControlBindingModels/ControlBoundControlBindingModelClassGenerator.cs index 0dfeb36..de28a71 100644 --- a/src/Vetuviem.SourceGenerator/Features/ControlBindingModels/ControlBoundControlBindingModelClassGenerator.cs +++ b/src/Vetuviem.SourceGenerator/Features/ControlBindingModels/ControlBoundControlBindingModelClassGenerator.cs @@ -81,6 +81,10 @@ protected override SeparatedSyntaxList GetTypeParameterSynt return sep; } + /// + protected override SyntaxToken[] GetConstructorModifiers(bool makeClassesPublic) => + [SyntaxFactory.Token(makeClassesPublic ? SyntaxKind.PublicKeyword : SyntaxKind.InternalKeyword)]; + /// protected override ClassDeclarationSyntax ApplyBaseClassDeclarationSyntax( INamedTypeSymbol namedTypeSymbol, diff --git a/src/Vetuviem.SourceGenerator/Features/ControlBindingModels/GenericControlBindingModelClassGenerator.cs b/src/Vetuviem.SourceGenerator/Features/ControlBindingModels/GenericControlBindingModelClassGenerator.cs index 02708e8..186f804 100644 --- a/src/Vetuviem.SourceGenerator/Features/ControlBindingModels/GenericControlBindingModelClassGenerator.cs +++ b/src/Vetuviem.SourceGenerator/Features/ControlBindingModels/GenericControlBindingModelClassGenerator.cs @@ -106,6 +106,10 @@ protected override SeparatedSyntaxList GetTypeParameterSynt return sep; } + /// + protected override SyntaxToken[] GetConstructorModifiers(bool _) => + [SyntaxFactory.Token(SyntaxKind.ProtectedKeyword)]; + /// protected override ClassDeclarationSyntax ApplyBaseClassDeclarationSyntax( INamedTypeSymbol namedTypeSymbol,