Do not show top-level-symbols inside type declarations#60131
Do not show top-level-symbols inside type declarations#60131CyrusNajmabadi merged 1 commit intodotnet:mainfrom
Conversation
| class MyClass | ||
| {{ | ||
| public static void F() | ||
| {{ | ||
| $$ | ||
| }} | ||
| }}"; |
There was a problem hiding this comment.
Consider adding a test for partial class Program { public static void F() { $$ } }
I have a feeling that the change will break this case. They should still be filtered. Nothing should be broken :)
| // filter our top level locals if we're inside a type declaration. | ||
| if (_context.ContainingTypeDeclaration != null) | ||
| symbols = symbols.WhereAsArray(s => s.ContainingSymbol.Name != WellKnownMemberNames.TopLevelStatementsEntryPointMethodName); |
There was a problem hiding this comment.
Why LookupSymbols is returning the extra symbols in the first place?
I could be wrong, but to me that looks like a compiler scoping issue where the compiler works-around it in:
roslyn/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
Lines 1920 to 1932 in c95d747
There was a problem hiding this comment.
Why LookupSymbols is returning the extra symbols in the first place?
I forget the exact reason, but it's int eh LDM notes. I think it's because if we want to add the facility for some top level symbols we can do so in a way that is sensible (e.g. imagine top level local functions in namespaces). @333fred may remember better. There's a subtle difference between not-visible, and visible-but-not-usable, and i recall there being reasons we wanted the latter.
No description provided.