Skip to content
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

Merge release/dev17.5 to release/dev17.6 #8358

Merged
11 commits merged into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void Execute(TagHelperDescriptorProviderContext context)
}
}

private bool IsTagHelperAssembly(IAssemblySymbol assembly)
internal static bool IsTagHelperAssembly(IAssemblySymbol assembly)
{
return assembly.Name != null && !assembly.Name.StartsWith("System.", StringComparison.Ordinal);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ public ViewComponentTypeVisitor(
_results = results;
}

public override void VisitAssembly(IAssemblySymbol symbol)
{
if (ViewComponentTagHelperDescriptorProvider.IsTagHelperAssembly(symbol))
{
Visit(symbol.GlobalNamespace);
}
}

public override void VisitNamedType(INamedTypeSymbol symbol)
{
if (IsViewComponent(symbol))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -855,21 +855,21 @@ private void RewriteNodesForComponentEventCallbackBind(
else if (setter == null && after != null)
{
// bind:after only
var afterToEventCallback = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}(this, callback: {after.Content})";
var afterContentInvocation = $"{ComponentsApi.RuntimeHelpers.InvokeAsynchronousDelegate}(callback: {after.Content})";
changeExpressionTokens.Add(new IntermediateToken()
{
Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: __value => {{ {original.Content} = __value; return {afterToEventCallback}.InvokeAsync(); }}, value: {original.Content})",
Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredBindSetter}(callback: __value => {{ {original.Content} = __value; return {afterContentInvocation}; }}, value: {original.Content})",
Kind = TokenKind.CSharp
});
}
else
{
// bind:set and bind:after create the code even though we disallow this combination through a diagnostic
var setToEventCallback = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: {setter.Content}, value: {original.Content})";
var afterToEventCallback = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}(this, callback: {after.Content})";
var setToEventCallback = $"{ComponentsApi.RuntimeHelpers.CreateInferredBindSetter}(callback: {setter.Content}, value: {original.Content})";
var afterContentInvocation = $"{ComponentsApi.RuntimeHelpers.InvokeAsynchronousDelegate}(callback: {after.Content})";
changeExpressionTokens.Add(new IntermediateToken()
{
Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: async __value => {{ await {setToEventCallback}.InvokeAsync(); await {afterToEventCallback}.InvokeAsync(); }}, value: {original.Content})",
Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: async __value => {{ await {setToEventCallback}; await {afterContentInvocation}; }}, value: {original.Content})",
Kind = TokenKind.CSharp
});
}
Expand Down Expand Up @@ -966,28 +966,28 @@ private void RewriteNodesForElementEventCallbackBind(
// bind:set only
changeExpressionTokens.Add(new IntermediateToken()
{
Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: {setter.Content}, value: {original.Content})",
Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredBindSetter}(callback: {setter.Content}, value: {original.Content})",
Kind = TokenKind.CSharp
});
}
else if (setter == null && after != null)
{
// bind:after only
var afterToEventCallback = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}(this, callback: {after.Content})";
var afterContentInvocation = $"{ComponentsApi.RuntimeHelpers.InvokeAsynchronousDelegate}(callback: {after.Content})";
changeExpressionTokens.Add(new IntermediateToken()
{
Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: __value => {{ {original.Content} = __value; return {afterToEventCallback}.InvokeAsync(); }}, value: {original.Content})",
Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredBindSetter}(callback: __value => {{ {original.Content} = __value; return {afterContentInvocation}; }}, value: {original.Content})",
Kind = TokenKind.CSharp
});
}
else
{
// bind:set and bind:after create the code even though we disallow this combination through a diagnostic
var setToEventCallback = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: {setter.Content}, value: {original.Content})";
var afterToEventCallback = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}(this, callback: {after.Content})";
var setterContentInvocation = $"{ComponentsApi.RuntimeHelpers.CreateInferredBindSetter}(callback: {setter.Content}, value: {original.Content})";
var afterContentInvocation = $"{ComponentsApi.RuntimeHelpers.InvokeAsynchronousDelegate}(callback: {after.Content})";
changeExpressionTokens.Add(new IntermediateToken()
{
Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: async __value => {{ await {setToEventCallback}.InvokeAsync(); await {afterToEventCallback}.InvokeAsync(); }}, value: {original.Content})",
Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: async __value => {{ await {setterContentInvocation}(); await {afterContentInvocation}; }}, value: {original.Content})",
Kind = TokenKind.CSharp
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public static class RuntimeHelpers
{
public const string TypeCheck = "global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck";
public const string CreateInferredEventCallback = "global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback";
public const string CreateInferredBindSetter = "global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredBindSetter";
public const string InvokeSynchronousDelegate = "global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate";
public const string InvokeAsynchronousDelegate = "global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate";
}
Expand Down
Loading