Skip to content
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

Reproducer for S1192 FP: SQL Named Parameters #9593

Merged
merged 5 commits into from
Aug 9, 2024

Conversation

zsolt-kolbay-sonarsource
Copy link
Contributor

Reproduces #9569

Copy link
Contributor

@sebastien-marichal sebastien-marichal left a comment

Choose a reason for hiding this comment

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

If this is relevant to the rule, I think you should put the dummy classes into the Dapper namespace or the right namespace.

Comment on lines 158 to 175
public class SqlCommand
{
public string CommandText { get; }
public SqlCommand(string commandText) => CommandText = commandText;
public void AddParameter(SqlParameter parameter) { }
public object ExecuteQuery() => null;
}

public class SqlParameter
{
public string Name { get; }
public string Value { get; }
public SqlParameter(string name, string value)
{
Name = name;
Value = value;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

To be sure, shouldn't those be in the Dapper namespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I originally wanted to create some dummy classes, so that the UT doesn't need to load Dapper and its dependencies.
But a real-world example is probably better. I changed the test case and moved it to a dedicated test file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: I think those test cases could be in a dedicated .Dapper.cs file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the test case and moved it to a dedicated test file.

Copy link
Contributor

@sebastien-marichal sebastien-marichal left a comment

Choose a reason for hiding this comment

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

The VB dedicated file for Dapper is missing.

@@ -58,6 +58,16 @@ public class StringLiteralShouldNotBeDuplicatedTest
.WithOptions(ParseOptionsHelper.FromCSharp11)
.Verify();

[TestMethod]
public void StringLiteralShouldNotBeDuplicated_CSharp_Dapper() =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick

Suggested change
public void StringLiteralShouldNotBeDuplicated_CSharp_Dapper() =>
public void StringLiteralShouldNotBeDuplicated_CS_Dapper() =>

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason not to move those changes to a .Dapper.vb file?

Copy link

sonarcloud bot commented Aug 9, 2024

Copy link

sonarcloud bot commented Aug 9, 2024

Copy link
Contributor

@sebastien-marichal sebastien-marichal left a comment

Choose a reason for hiding this comment

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

LGTM!

@sebastien-marichal sebastien-marichal merged commit 1ed786e into master Aug 9, 2024
20 checks passed
@sebastien-marichal sebastien-marichal deleted the Zsolt/S1192-FP-SQL-parameters-repro branch August 9, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants