Skip to content

Adds an attribute called IgnoreProperty that tells the generator to skip the property#44

Merged
StefH merged 6 commits intoStefH:mainfrom
emorell96:main
Jul 12, 2022
Merged

Adds an attribute called IgnoreProperty that tells the generator to skip the property#44
StefH merged 6 commits intoStefH:mainfrom
emorell96:main

Conversation

@emorell96
Copy link
Copy Markdown
Contributor

I added an attribute that allows the user to set some properties as ignored for more control when generating a builder.

It allows me to bypass #43 by ignoring the property that breaks the code.

I tested the attribute by adding it to the SimpleClass and the test FluentBuilderGeneratorTests.FluentBuilderSourceGeneratorTests.GenerateFiles_ForSimpleClass_Should_GenerateCorrectFiles should fail if the property is not skipped since the generated code wouldn't match the expected code.

The test passes, as do all the others:
image

… previous attribute that I defined is not introduced into the user's code.
…ally in the same namespace. if you know a better way to test this feel free to change it.
@emorell96 emorell96 marked this pull request as draft June 30, 2022 20:38
Ran the tests so that the autogenerator would inject the IgnoreProperty attribute into the tests and I could comment out the "cheat" attribute in SimpleClass.cs
I also packed a dev version and installed it on my own current project and the ignore attribute works as expected.
@emorell96 emorell96 marked this pull request as ready for review June 30, 2022 21:15
@emorell96
Copy link
Copy Markdown
Contributor Author

Ok this PR is ready. I have moved the attribute to the Attribute Generator. And it works as expected.

.AppendLine(" });");
}

private const string IgnoreAttributeClassName = "FluentBuilder.IgnorePropertyAttribute";
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move const to top of the file

@StefH
Copy link
Copy Markdown
Owner

StefH commented Jul 1, 2022

@emorell96
thank you.

please see my code review

@emorell96
Copy link
Copy Markdown
Contributor Author

I'll get to them during the weekend :) I think they are a good idea.

@StefH StefH added the enhancement New feature or request label Jul 1, 2022
@StefH
Copy link
Copy Markdown
Owner

StefH commented Jul 9, 2022

@emorell96 Did you have time yet to fix the comments?

@StefH
Copy link
Copy Markdown
Owner

StefH commented Jul 10, 2022

@emorell96 If you don't have the time, that's also fine. I can take over your branch/PR and update it.

@StefH StefH merged commit f0beacb into StefH:main Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants