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

C#: Add cs/invalid-string-formatting to the codeql quality suite. #19148

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

michaelnebel
Copy link
Contributor

@michaelnebel michaelnebel commented Mar 28, 2025

In this PR we

  • Add the cs/invalid-string-formatting to the code quality suite.
  • Re-write tests to use inline expectations tests; In this process a couple of faulty testcases were discovered and these were corrected (for instance - we only check that format strings are valid in case there are insertions).
  • Remove false positives related to Console.WriteLine(string) and friends. A saw some examples using MRVA where it was intentional to write Console.WriteLine("{0}") - so this shouldn't be flagged as an issue.
  • Add new results for string.Format where no additional arguments are provided (for instance string.Format("{") causes a runtime crash and this was not detected prior to this change).

The number of results produced by DCA Looks acceptable.
Also spot checked results with MRVA - they look fine as well.

@github-actions github-actions bot added the C# label Mar 28, 2025
@michaelnebel michaelnebel force-pushed the csharp/invalid-string-format branch 3 times, most recently from a90b204 to 375b3d0 Compare April 4, 2025 08:57
@michaelnebel michaelnebel force-pushed the csharp/invalid-string-format branch from 375b3d0 to cfe6cbd Compare April 4, 2025 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant