Add activity log for TagHelper exceptions
This will log to the VS activity log any time we fail to discovery taghelpers due to an exception. There's no real user experience around this... if someone is having an issue we can ask them to send us the log or post the relevant portion.
This commit is contained in:
parent
f0d5461e31
commit
f177648c88
|
|
@ -10,6 +10,8 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNetCore.Razor.Evolution;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
using Microsoft.VisualStudio.Shell;
|
||||
using Microsoft.VisualStudio.Shell.Interop;
|
||||
|
||||
namespace Microsoft.VisualStudio.LanguageServices.Razor
|
||||
{
|
||||
|
|
@ -19,6 +21,9 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
[Import]
|
||||
public VisualStudioWorkspace Workspace { get; set; }
|
||||
|
||||
[Import]
|
||||
public SVsServiceProvider Services { get; set; }
|
||||
|
||||
public async Task<TagHelperResolutionResult> GetTagHelpersAsync(Project project, IEnumerable<string> assemblyNameFilters)
|
||||
{
|
||||
try
|
||||
|
|
@ -46,6 +51,16 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
var log = GetActivityLog();
|
||||
if (log != null)
|
||||
{
|
||||
var hr = log.LogEntry(
|
||||
(uint)__ACTIVITYLOG_ENTRYTYPE.ALE_ERROR,
|
||||
"Razor Language Services",
|
||||
$"Error discovering TagHelpers:{Environment.NewLine}{exception}");
|
||||
ErrorHandler.ThrowOnFailure(hr);
|
||||
}
|
||||
|
||||
throw new RazorLanguageServiceException(
|
||||
typeof(DefaultTagHelperResolver).FullName,
|
||||
nameof(GetTagHelpersAsync),
|
||||
|
|
@ -90,5 +105,11 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IVsActivityLog GetActivityLog()
|
||||
{
|
||||
var services = (IServiceProvider)Services;
|
||||
return services.GetService(typeof(SVsActivityLog)) as IVsActivityLog;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,18 @@
|
|||
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="2.0.0-rc3-61306-01" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.LanguageServices" Version="2.0.0-rc3-61306-01" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.LanguageServices.Razor.RemoteClient" Version="2.0.0-rc3-61306-01" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.OLE.Interop" Version="7.10.6070" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Shell.14.0" Version="14.3.25407" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Shell.Immutable.10.0" Version="10.0.30319" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Shell.Immutable.11.0" Version="11.0.50727" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Shell.Immutable.12.0" Version="12.0.21003" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Shell.Immutable.14.0" Version="14.3.25407" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop" Version="7.10.6071" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.8.0" Version="8.0.50727" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.9.0" Version="9.0.30729" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.10.0" Version="10.0.30319" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.11.0" Version="11.0.61030" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.12.0" Version="12.0.30110" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.CodeAnalysis.Razor.Workspaces\Microsoft.CodeAnalysis.Razor.Workspaces.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor.Evolution\Microsoft.AspNetCore.Razor.Evolution.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
Loading…
Reference in New Issue