-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
File types IDE changes #62215
File types IDE changes #62215
Conversation
Just realized this won't pass CI until #61646 is merged 😅. Should still be reviewable though. |
...kspaces/SharedUtilitiesAndExtensions/Compiler/Core/SymbolKey/SymbolKey.NamedTypeSymbolKey.cs
Outdated
Show resolved
Hide resolved
...kspaces/SharedUtilitiesAndExtensions/Compiler/Core/SymbolKey/SymbolKey.NamedTypeSymbolKey.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/KeywordCompletionProviderTests.cs
Show resolved
Hide resolved
@@ -203,6 +211,7 @@ private enum Modifiers | |||
Volatile = 1 << 14, | |||
Extern = 1 << 15, | |||
Required = 1 << 16, | |||
File = 1 << 17, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you added this API, consider fixing up:
Consider also updating
roslyn/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
Lines 1491 to 1492 in 5510ef9
case SyntaxKind.DelegateDeclaration: | |
return DeclarationModifiers.New | DeclarationModifiers.Unsafe; |
roslyn/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
Lines 1444 to 1466 in 5510ef9
private static readonly DeclarationModifiers s_classModifiers = | |
DeclarationModifiers.Abstract | | |
DeclarationModifiers.New | | |
DeclarationModifiers.Partial | | |
DeclarationModifiers.Sealed | | |
DeclarationModifiers.Static | | |
DeclarationModifiers.Unsafe; | |
private static readonly DeclarationModifiers s_recordModifiers = | |
DeclarationModifiers.Abstract | | |
DeclarationModifiers.New | | |
DeclarationModifiers.Partial | | |
DeclarationModifiers.Sealed | | |
DeclarationModifiers.Unsafe; | |
private static readonly DeclarationModifiers s_structModifiers = | |
DeclarationModifiers.New | | |
DeclarationModifiers.Partial | | |
DeclarationModifiers.ReadOnly | | |
DeclarationModifiers.Ref | | |
DeclarationModifiers.Unsafe; | |
private static readonly DeclarationModifiers s_interfaceModifiers = DeclarationModifiers.New | DeclarationModifiers.Partial | DeclarationModifiers.Unsafe; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It actually wasn't clear to me whether 'file' should be added to this. I assume if the IDE has need to generate syntax for a file type, it would use this. But I don't know if the use case exists. It would be helpful to know whether I should delete and just stub out a bool IsFIle => false;
implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RikkiGibson This is a public API. So it's very necessary that 'file' is added here (not necessarily in this PR)
A common SyntaxGenerator usage pattern is generator.WithModifiers(node, generator.GetModifiers(node).WithIsX(true))
If the node with a class declaration for file class C { }
, and we called WithIsSealed(true)
(for example), I expect the resulting node will drop file
if the change is not made.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Youssef1313 is correct. thanks! :)
/// <summary> | ||
/// Indicates the type is declared in source and is only visible in the file it is declared in. | ||
/// </summary> | ||
bool IsFile { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 For the record, the API review for this is tracked by #62254
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done with review pass, compiler changes only (iteration 14)
Co-authored-by: Youssef Victor <youssefvictor00@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm with the changes suggested by @Youssef1313 . thanks!
[InlineData("struct", TypeKind.Struct)] | ||
[InlineData("interface", TypeKind.Interface)] | ||
[InlineData("enum", TypeKind.Enum)] | ||
public async Task AddFileType(string kindString, TypeKind typeKind) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't able to figure out how to properly test 'delegate', 'record', or 'record struct' here.
- 'delegate' got me a test crash with a stacktrace consisting only of async thunks..
- I didn't see how to specify 'record' and 'record struct' in here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect the lack of file being handled here to cause problems with a public API path:
Lines 126 to 143 in 1fcfda5
modifiers |= token.Kind() switch | |
{ | |
SyntaxKind.AbstractKeyword => DeclarationModifiers.Abstract, | |
SyntaxKind.NewKeyword => DeclarationModifiers.New, | |
SyntaxKind.OverrideKeyword => DeclarationModifiers.Override, | |
SyntaxKind.VirtualKeyword => DeclarationModifiers.Virtual, | |
SyntaxKind.StaticKeyword => DeclarationModifiers.Static, | |
SyntaxKind.AsyncKeyword => DeclarationModifiers.Async, | |
SyntaxKind.ConstKeyword => DeclarationModifiers.Const, | |
SyntaxKind.ReadOnlyKeyword => DeclarationModifiers.ReadOnly, | |
SyntaxKind.SealedKeyword => DeclarationModifiers.Sealed, | |
SyntaxKind.UnsafeKeyword => DeclarationModifiers.Unsafe, | |
SyntaxKind.PartialKeyword => DeclarationModifiers.Partial, | |
SyntaxKind.RefKeyword => DeclarationModifiers.Ref, | |
SyntaxKind.VolatileKeyword => DeclarationModifiers.Volatile, | |
SyntaxKind.ExternKeyword => DeclarationModifiers.Extern, | |
_ => DeclarationModifiers.None, | |
}; |
Are you able to identify a specific editor feature/scenario which will behave incorrectly? I may prefer to file an issue |
I'll take a look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiler-side LGTM Thanks (iteration 20)
Related to #60819
@dibarbet for review. This gets us to the min-bar for IDE support.
The SymbolKey changes are important here. Without them EnC will not work at all with the feature. With them we can do some simple EnC without crashing in the IDE. It will still fail when files are added or removed during an EnC session but we anticipate solving that after merging the feature to main, before RTM. #61999