-
Notifications
You must be signed in to change notification settings - Fork 230
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 S2234 Bug: AD0001 is thrown due to referencing a location outside of the current compilation #8577
Comments
Hello @rjgotten, Thank you for reporting this issue. So I must ask, is there a chance you could provide a very simplistic version of your issue? If this is really not possible, I would need you to describe your issue in more detail. Thank you. |
@sebastien-marichal The AD0001 is raised on a violation of S2234 inside the We actually specifically suppress S2234 from being raised via pragmas. [Test]
public void Constructor_InvertedRange_Throws()
{
var start = DateTime.Parse("2021-01-01T10:00", CultureInfo.InvariantCulture);
var end = DateTime.Parse("2021-01-01T11:00", CultureInfo.InvariantCulture);
Assert.Multiple(() =>
{
#pragma warning disable S2234 // Parameters should be passed in the correct order
Assert.That(() => new DateTimeRange(start, end), Throws.Nothing);
Assert.That(() => new DateTimeRange(end, start), Throws.ArgumentException);
#pragma warning restore S2234 // Parameters should be passed in the correct order
});
} |
Hello @rjgotten, I am still not able to reproduce your issue. Unfortunately, without a proper reproducer, we won't be able to confirm the issue is fixed. I will add this issue to the backlog to fix the bug. When reporting an issue (see here) we make sure the primary location is part of the compilation, if not we do not raise the issue due to potential AD0001. We should probably do the same for the secondary locations as well. |
... huh. Lightbulb moment 💡 Have one suggestion though: |
To make it more explicit, when a secondary location is not part of the compilation, we have two possible solutions:
|
Description
Repro steps
Impossible to provide as an inline code sample or as a sample project.
Issue occurs with a complex setup where the class being analyzed ends up not being part of the current partial compilation unit handled by Roslyn. This can likely only be accurately reproduced with the full solution which I am not at liberty to share access to.
This worked with SonarLint v7.4.0.80741 and SonarC# v9.12.0.78982.
It broke with SonarLint v7.5.0.82292 and SonarC# v9.15.0.81779.
So at least you have a bisection window.
Known workarounds
.editorconfig
; situational suppressing via pragma or attribute does not work.Related information
The text was updated successfully, but these errors were encountered: