You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding a StringBuilder(char) constructor was originally proposed in Add StringBuilder(Char) #20848 due to the existing StringBuilder(int capacity) constructor accepting a char as an argument (i.e.: StringBuilder('a')), but the proposal was finally rejected.
Since this scenario will generally denote a bug, the possibility of creating an analyzer for it was brought up during the review of the proposal, but apparently was discarded or never formalized.
I wonder if this can be turned into a generalized heuristic. Some possible examples:
If the parameter is named capacity, count, or similar; and if the input to the parameter is a char which has been auto-widened to an int; trigger the analyzer.
If there are two method overloads MyMethod(..., string, ...) and MyMethod(..., int, ...) (but no MyMethod(..., char, ...)), and if the call site matched the second overload because a char was auto-widened to an int, trigger the analyzer.
This has shown very little interest and is unlikely to happen given the size of the backlog and number of requests we get.
While it is a quirk and potential issue for some APIs, it should be relatively quickly got given even basic tests and so is likely not a huge issue in practice.
Activity
Dotnet-GitSync-Bot commentedon Dec 15, 2020
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
GrabYourPitchforks commentedon Dec 16, 2020
I wonder if this can be turned into a generalized heuristic. Some possible examples:
If the parameter is named capacity, count, or similar; and if the input to the parameter is a char which has been auto-widened to an int; trigger the analyzer.
If there are two method overloads
MyMethod(..., string, ...)andMyMethod(..., int, ...)(but noMyMethod(..., char, ...)), and if the call site matched the second overload because a char was auto-widened to an int, trigger the analyzer.tannergooding commentedon Jul 11, 2026
This has shown very little interest and is unlikely to happen given the size of the backlog and number of requests we get.
While it is a quirk and potential issue for some APIs, it should be relatively quickly got given even basic tests and so is likely not a huge issue in practice.