IntentArchitect / Support

A repository dedicated to handling issues and support queries
3 stars 0 forks source link

How to Ignore comments in a generated class #62

Closed nixonad closed 5 months ago

nixonad commented 10 months ago

Ask a question

How can I stop Intent from removing miscellaneous comments in my code? I have a domain entity created using the std modules, it has the default generated Intent headers:

    [IntentManaged(Mode.Merge, Signature = Mode.Fully)]
    [DefaultIntentManaged(Mode.Fully, Targets = Targets.Properties)]
    [DefaultIntentManaged(Mode.Fully, Targets = Targets.Methods | Targets.Constructors, Body = Mode.Ignore, AccessModifiers = AccessModifiers.Public)]

My comments which I added in the class are removed by Intent on running the Software Factory. Making the whole class IntentIgnore stops it from removing my comments but that's not ideal.

nixonad commented 10 months ago

I have found that changing the Intent attributes as follows works:

    [IntentManaged(Mode.Merge, Signature = Mode.Fully)]
    [DefaultIntentManaged(Mode.Fully, Targets = Targets.Properties, **Comments = Mode.Ignore**)]
    [DefaultIntentManaged(Mode.Fully, Targets = Targets.Methods | Targets.Constructors, **Comments = Mode.Ignore**, Body = Mode.Ignore, AccessModifiers = AccessModifiers.Public)]

I had thought that changing the IntentManaged attribute on the class would work but it does not.

Is there then a way to make Comments = Mode.Ignore the default for generated code? Thanks

JonathanLydall commented 10 months ago

Hi @nixonad,

Glad to see you came right.

In regard to the [IntentManaged(…)] attribute not having an effect in this case, this is to be expected as they don't apply to descendant syntax nodes (members in this case) except when they are [IntentManaged(Mode.Ignore)], so updating the [DefaultIntentManaged(…)] attribute was the way to go.

There is no global setting to make Comments globally ignored, however, we've logged an issue on our side about possibly making attributes like [IntentManaged(Mode.Fully, Comments = Mode.ignore)] also apply the ignoring of Comments to descendant nodes.

JonathanLydall commented 10 months ago

Hi @nixonad,

I wanted to add some additional feedback that we are looking into methods to globally control code management behaviour and are keeping in mind this kind of request as part of that feature.

Also, just as a reminder, these comments can also be captured in designers in Intent Architect in which case it will generate them for you:

image

JonathanLydall commented 5 months ago

Hi @nixonad,

To come back to this, we have since added an application setting to make this the default everywhere if you want to try this out:

image

I'm closing this issue, but happy to reopen it if you have any comments or questions.