-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix doubled braces in attributes #412
Conversation
Wow! Not reproducable locally, but reproducable in CI. |
There are no doubled (( on NET FRAMEWORK. |
Okay, then it makes more sense. |
// https://github.com/PublicApiGenerator/PublicApiGenerator/issues/410 | ||
if (gennedClass.Contains(ATTRIBUTE_MARKER_AND_DOUBLED_BRACE) && gennedClass.Contains(DOUBLED_CLOSING_BRACE_IN_ATTRIBUTE)) | ||
{ | ||
gennedClass = gennedClass.Replace(ATTRIBUTE_MARKER_AND_DOUBLED_BRACE, ATTRIBUTE_MARKER_AND_BRACE); | ||
gennedClass = gennedClass.Replace(DOUBLED_CLOSING_BRACE_IN_ATTRIBUTE, SINGLE_CLOSING_BRACE_IN_ATTRIBUTE); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work with the example from #410 because it has an extra parameter after the long string.
[Fact]
public void Should_handle_attribute_with_long_string_initialiser2()
{
AssertPublicApi<ClassWithAttributeWithLongStringInitialiser2>(
@"namespace PublicApiGeneratorTests.Examples
{
[System.Obsolete(""This is a veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"" +
""eeeeeeery long string that will be surrounded by parenthesis due to how it\'s han"" +
""dled by Microsoft.CodeDom"", false)]
public class ClassWithAttributeWithLongStringInitialiser2
{
public ClassWithAttributeWithLongStringInitialiser2() { }
}
}");
}
[Obsolete("This is a veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeery long string that will be surrounded by parenthesis due to how it's handled by Microsoft.CodeDom", false)]
public class ClassWithAttributeWithLongStringInitialiser2()
{
}
There's also other cases to consider:
- Ending with long string parameter
[SomeAttribute(false, "loooong string")]
- Multiple long strings parameters
[SomeAttribute("loooong string", "loooong string")]
Looking at the commit history for System.CodeDom
dotnet/runtime#96948 is the only change between 8.0.0 and 9.0.0.
Skimming the fixed issue, I'm not sure if the fix is relevant for PublicApiGenerator.
So how about:
- Downgrade
System.CodeDom
to 8.0.0 - Undo the changes to
CodeNormalizer
- Keep
Should_handle_attribute_with_long_string_initialiser
as a regression test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. It turned out to be not so easy to fix this error only by replacing lines. As a result, I copied all needed code to generate results and commented out problem line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All tests are green now.
Downgrade System.CodeDom to 8.0.0
I understand but downgrading may lead to additional noise with dependabot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dependabot should keep silent if we fix the version using Version=[8.0.0]
.
In Fluent Assertions, we have configured dependabot to ignore certain dependecies
https://github.com/fluentassertions/fluentassertions/blob/ec0192465b6009ff356c31eeee9adf4187b2496e/.github/dependabot.yml#L27-L37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that feature. Nevertheless I'm 50/50 now to go on with these changes or revert to 8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jnyrup I achieved a minimum possible diff to fix this issue. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #412 +/- ##
===========================================
- Coverage 86.24% 29.90% -56.35%
===========================================
Files 21 26 +5
Lines 1345 3879 +2534
Branches 239 634 +395
===========================================
Hits 1160 1160
- Misses 147 2674 +2527
- Partials 38 45 +7 ☔ View full report in Codecov by Sentry. |
fixes #410
This PR was superseded by #414.