-
Notifications
You must be signed in to change notification settings - Fork 199
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
[FUSE] Provide intellisense for @inject directives #10771
Changes from all commits
b80d39f
4cd7c94
c9b4aea
df8c74a
41b5534
2e88d74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,3 +60,6 @@ | |
Inject - | ||
Inject - | ||
Inject - | ||
Inject - | ||
Inject - | ||
Inject - |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,49 @@ | ||
#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "844eb91b909a14b78feddd5e6866563b5a75e021" | ||
#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "c83d1c26cf039a87fc6aedc860fd9d28a34d96dfb2e405e6af3918602ca27755" | ||
// <auto-generated/> | ||
#pragma warning disable 1591 | ||
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml")] | ||
namespace AspNetCore | ||
{ | ||
#line hidden | ||
#line default | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.Rendering; | ||
using Microsoft.AspNetCore.Mvc.ViewFeatures; | ||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic> | ||
#line default | ||
#line hidden | ||
[global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"Sha256", @"c83d1c26cf039a87fc6aedc860fd9d28a34d96dfb2e405e6af3918602ca27755", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml")] | ||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic> | ||
{ | ||
#pragma warning disable 1998 | ||
public async override global::System.Threading.Tasks.Task ExecuteAsync() | ||
{ | ||
BeginContext(83, 4, true); | ||
WriteLiteral("\r\n\r\n"); | ||
EndContext(); | ||
BeginContext(93, 2, true); | ||
WriteLiteral("\r\n"); | ||
EndContext(); | ||
BeginContext(102, 4, true); | ||
WriteLiteral("\r\n"); | ||
WriteLiteral("\r\n\r\n"); | ||
EndContext(); | ||
BeginContext(113, 2, true); | ||
WriteLiteral("\r\n"); | ||
EndContext(); | ||
BeginContext(123, 2, true); | ||
WriteLiteral("\r\n"); | ||
EndContext(); | ||
BeginContext(150, 2, true); | ||
WriteLiteral("\r\n"); | ||
EndContext(); | ||
} | ||
#pragma warning restore 1998 | ||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] | ||
public | ||
#line (8,9)-(8,18) "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" | ||
MyService<dynamic> | ||
|
||
#line default | ||
#line hidden | ||
Member_test { get; private set; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wen have two places where we set it. A whole bunch of other places were using the other one, so it made the diff huge. I'll submit a follow up PR to make them consistent. |
||
#line (7,9)-(7,9) "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" | ||
|
||
#line default | ||
#line hidden | ||
#line (6,8)-(6,8) "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" | ||
|
||
#line default | ||
#line hidden | ||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] | ||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; } | ||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,7): Error RZ9999: The 'model' directive expects a type name. | ||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ9999: The 'model' directive may only occur once per document. | ||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,8): Error RZ9999: The 'model' directive expects a type name. | ||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(6,8): Error RZ9999: The 'inject' directive expects a type name. | ||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,9): Error RZ9999: The 'inject' directive expects a type name. | ||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,26): Error RZ9999: The 'inject' directive expects an identifier. | ||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,7): Error RZ1013: The 'model' directive expects a type name. | ||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ2001: The 'model' directive may only occur once per document. | ||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,8): Error RZ1013: The 'model' directive expects a type name. | ||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(6,8): Error RZ1013: The 'inject' directive expects a type name. | ||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,9): Error RZ1013: The 'inject' directive expects a type name. | ||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,26): Error RZ1015: The 'inject' directive expects an identifier. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Source Location: (133:7,8 [9] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) | ||
|MyService| | ||
Generated Location: (1895:33,0 [9] ) | ||
|MyService| | ||
|
||
Source Location: (123:6,8 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) | ||
|| | ||
Generated Location: (2096:39,0 [0] ) | ||
|| | ||
|
||
Source Location: (113:5,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml) | ||
|| | ||
Generated Location: (2233:43,0 [0] ) | ||
|| | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,23 @@ public void SupportsInjectDirective() | |
s => AssertEx.Equal("private TestNamespace.IMyService2 Test.TestComponent.MyService2 { get; set; }", s.ToTestDisplayString())); | ||
} | ||
|
||
[Fact] | ||
public void SupportsIncompleteInjectDirectives() | ||
{ | ||
var component = CompileToComponent(""" | ||
@inject | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not clear to me how this resolves the issue. The issue talks about IntelliSense on the type part and when user writes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am also confused here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's always been true. You don't get IntelliSense until you type the first character today. Once you type the first character, you get it, but in fuse you never get it until you start typing the name: Not-fuse: Fuse (broken): Fuse (fixed): Note, this is same behavior you get today in C#, if you're e.g. writing a new property: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In C#, can't you manually bring up completion though? What's the equivalent behavior in razor currently? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok, so if you invoke IntelliSense in either the C# or non-fuse razor case, you just get an empty IntelliSense box. In the PR right now you get nothing, because we have nothing emitted. In design time that works by mapping to just a totally empty space. We can probably do that here too to get exactly the same behavior. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Lol, wrote this then almost immediately figured it out. Update incoming. |
||
@inject DateTime | ||
@inject DateTime Value | ||
"""); | ||
|
||
// Assert 1: Compiled type has correct properties | ||
var injectableProperties = component.GetMembers().OfType<IPropertySymbol>() | ||
.Where(p => p.GetAttributes().Any(a => a.AttributeClass.Name == "InjectAttribute")); | ||
Assert.Collection(injectableProperties.OrderBy(p => p.Name), | ||
s => AssertEx.Equal("private System.DateTime Test.TestComponent.Member___UniqueIdSuppressedForTesting__ { get; set; }", s.ToTestDisplayString()), | ||
s => AssertEx.Equal("private System.DateTime Test.TestComponent.Value { get; set; }", s.ToTestDisplayString())); | ||
} | ||
|
||
private const string AdditionalCode = | ||
""" | ||
using Microsoft.AspNetCore.Components; | ||
|
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.
These files existed, because apparently the test did at one point, too, but they were super out of date, so I would just review these as newly added.