Add support for partial component class editing -> refresh components.

- We now do aggressive detection on the type of C# class that's being edited. In order to not impact C# scenarios we only do work if C# assets are available to us. Meaning, we inspect the old document and if that document has its' semantic model available we spend cycles to determine if it's a component. In the case that we find a C# component class that wasn't previously caught we enqueue an update.
- Added several tests to ensure we enqueue and that we properly detect component classes.

aspnet/AspNetCoredotnet/aspnetcore-tooling#14646
\n\nCommit migrated from d8b62e121f
This commit is contained in:
N. Taylor Mullen 2019-10-15 10:29:33 -07:00
parent 82e62cb34f
commit 163c09f984
2 changed files with 30 additions and 4 deletions

View File

@ -0,0 +1,28 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.CodeAnalysis.Razor
{
internal static class ComponentDetectionConventions
{
public static bool IsComponent(INamedTypeSymbol symbol, INamedTypeSymbol icomponentSymbol)
{
if (symbol is null)
{
throw new ArgumentNullException(nameof(symbol));
}
if (icomponentSymbol is null)
{
throw new ArgumentNullException(nameof(icomponentSymbol));
}
return
symbol.DeclaredAccessibility == Accessibility.Public &&
!symbol.IsAbstract &&
symbol.AllInterfaces.Contains(icomponentSymbol);
}
}
}

View File

@ -573,10 +573,8 @@ namespace Microsoft.CodeAnalysis.Razor
return false;
}
return
symbol.DeclaredAccessibility == Accessibility.Public &&
!symbol.IsAbstract &&
symbol.AllInterfaces.Contains(_symbols.IComponent);
var isComponent = ComponentDetectionConventions.IsComponent(symbol, _symbols.IComponent);
return isComponent;
}
}
}