-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
HashTable
use in code emitted by [GeneratedRegex]
#110112
Comments
HashTable
use in code emitted by RegexGenerator
HashTable
use in code emitted by [GeneratedRegex]
The property being assigned to, |
And that's because these properties store the data into fields that are exposed and are strongly-typed as Hashtable: runtime/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs Lines 28 to 29 in f1332ab
It's an unfortunate legacy design that we can't change without it being massively breaking, due to these being public (protected) surface area. |
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions |
Ah, just another case of the consequences of breaking change prevention rearing its ugly head, then. Guess I'll just have to figure out how to disable the analyzer for generated files or stop using capture groups there, no big deal. Thanks for the answers! |
I added the
BannedApisAnalyzer
to my project to ban all the obsolete stuff like non-generic collections,WebClient
, and so on. To my surprise, I got a warning coming fromRegexGenerator.g.cs
file about the use ofHashTable
. And, sure enough, the generated code does use it, when the regex contains named capture groups.generates
I checked out the source code of the generator (click) and it is, indeed, what is supposed to be emitted:
I was wondering if there's any specific reason to use a
HashTable
here, instead of aDictionary<string, int>
? It seemed to me that non-generic collections are kept in the language still pretty much only for backward compatibility purposes, and new code should not be using them, in favor of lists and dictionaries.And here it is, some pretty dang new code still referencing them.
The text was updated successfully, but these errors were encountered: