-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Avoid global:: qualifying all names in the Regex source generator #63512
Comments
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions Issue DetailsBlocked on dotnet/csharplang#5529 In the Regex source generator, we currently fully-qualify with global:: every name to something in the core libraries, e.g. Once we have a solution to dotnet/csharplang#5529, we can spit the Regex-derived type into its own namespace, and put usings inside that namespace for all of the
|
cc: @jaredpar |
Wouldn't aliasing work here in this case!?
|
No. Beyond that resulting in similarly less readable code, it doesn't actually solve the problem. |
This should / could also be done for e.g. the LoggerMessages generated by the source generator. |
Yes, I'm using Regex as a case study for all of these as it's new in 7, but we should adopt similar strategies for our other generators, including the DllImport generator that's also new in 7. |
Blocked on dotnet/csharplang#5529
In the Regex source generator, we currently fully-qualify with global:: every name to something in the core libraries, e.g.
global::System.MemoryExtensions.IndexOf(span, value)
rather thanspan.IndexOf(value)
. This is done to avoid accidentally referencing something of the same name in the user's code, but it also leads to generating code that's much harder to read (and the generator itself is more verbose).Once we have a solution to dotnet/csharplang#5529, we can spit the Regex-derived type into its own namespace, and put usings inside that namespace for all of the
System.*
namespaces we consume. At that point, we will no longer need to fully-qualify and can go back to using simple names, using extension methods as extensions, etc.The text was updated successfully, but these errors were encountered: