Add CodeAnalysis.Razor to the vsix
Also adds some error handling so you can know if something went wrong.
This commit is contained in:
parent
62420209a5
commit
d72cd469bd
|
|
@ -343,6 +343,14 @@
|
|||
<IncludeOutputGroupsInVSIXLocalOnly>
|
||||
</IncludeOutputGroupsInVSIXLocalOnly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\src\Microsoft.CodeAnalysis.Razor.Workspaces\Microsoft.CodeAnalysis.Razor.csproj">
|
||||
<Name>Microsoft.CodeAnalysis.Razor</Name>
|
||||
<Private>False</Private>
|
||||
<IncludeOutputGroupsInVSIX>
|
||||
</IncludeOutputGroupsInVSIX>
|
||||
<IncludeOutputGroupsInVSIXLocalOnly>
|
||||
</IncludeOutputGroupsInVSIXLocalOnly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\src\Microsoft.CodeAnalysis.Razor.Workspaces\Microsoft.CodeAnalysis.Razor.Workspaces.csproj">
|
||||
<Project>{0f265874-c592-448b-bc4f-3430ab03e0dc}</Project>
|
||||
<Name>Microsoft.CodeAnalysis.Razor.Workspaces</Name>
|
||||
|
|
@ -375,6 +383,7 @@
|
|||
<ItemGroup>
|
||||
<VSIXSourceItem Include="..\..\src\Microsoft.CodeAnalysis.Remote.Razor\bin\$(Configuration)\net46\Microsoft.CodeAnalysis.Remote.Razor.dll" />
|
||||
<VSIXSourceItem Include="..\..\src\Microsoft.VisualStudio.LanguageServices.Razor\bin\$(Configuration)\net46\Microsoft.AspNetCore.Razor.Evolution.dll" />
|
||||
<VSIXSourceItem Include="..\..\src\Microsoft.VisualStudio.LanguageServices.Razor\bin\$(Configuration)\net46\Microsoft.CodeAnalysis.Razor.dll" />
|
||||
<VSIXSourceItem Include="..\..\src\Microsoft.VisualStudio.LanguageServices.Razor\bin\$(Configuration)\net46\Microsoft.CodeAnalysis.Razor.Workspaces.dll" />
|
||||
<VSIXSourceItem Include="..\..\src\Microsoft.VisualStudio.LanguageServices.Razor\bin\$(Configuration)\net46\Microsoft.VisualStudio.LanguageServices.Razor.dll" />
|
||||
<Content Include="@(VSIXSourceItem)">
|
||||
|
|
|
|||
|
|
@ -11,6 +11,14 @@ using Microsoft.VisualStudio.Shell;
|
|||
OldVersionUpperBound = "1.2.0.0",
|
||||
NewVersion = "1.2.0.0")]
|
||||
|
||||
[assembly: ProvideBindingRedirection(
|
||||
AssemblyName = "Microsoft.CodeAnalysis.Razor",
|
||||
GenerateCodeBase = true,
|
||||
PublicKeyToken = "adb9793829ddae60",
|
||||
OldVersionLowerBound = "0.0.0.0",
|
||||
OldVersionUpperBound = "1.2.0.0",
|
||||
NewVersion = "1.2.0.0")]
|
||||
|
||||
[assembly: ProvideBindingRedirection(
|
||||
AssemblyName = "Microsoft.CodeAnalysis.Razor.Workspaces",
|
||||
GenerateCodeBase = true,
|
||||
|
|
|
|||
|
|
@ -3,11 +3,12 @@
|
|||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.VisualStudio.Shell;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.VisualStudio.ComponentModelHost;
|
||||
using Microsoft.VisualStudio.LanguageServices;
|
||||
using Microsoft.VisualStudio.LanguageServices.Razor;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.VisualStudio.Shell;
|
||||
using Microsoft.VisualStudio.Shell.Interop;
|
||||
|
||||
namespace Microsoft.VisualStudio.RazorExtension.RazorInfo
|
||||
{
|
||||
|
|
@ -39,6 +40,8 @@ namespace Microsoft.VisualStudio.RazorExtension.RazorInfo
|
|||
|
||||
_workspace = componentModel.GetService<VisualStudioWorkspace>();
|
||||
_workspace.WorkspaceChanged += Workspace_WorkspaceChanged;
|
||||
|
||||
Reset(_workspace.CurrentSolution);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
|
|
@ -59,7 +62,7 @@ namespace Microsoft.VisualStudio.RazorExtension.RazorInfo
|
|||
return;
|
||||
}
|
||||
|
||||
var viewModel = new RazorInfoViewModel(this, _workspace, _assemblyResolver, _directiveResolver, _tagHelperResolver, _documentGenerator);
|
||||
var viewModel = new RazorInfoViewModel(this, _workspace, _assemblyResolver, _directiveResolver, _tagHelperResolver, _documentGenerator, OnException);
|
||||
foreach (var project in solution.Projects)
|
||||
{
|
||||
viewModel.Projects.Add(new ProjectViewModel(project));
|
||||
|
|
@ -68,6 +71,17 @@ namespace Microsoft.VisualStudio.RazorExtension.RazorInfo
|
|||
((RazorInfoToolWindowControl)this.Content).DataContext = viewModel;
|
||||
}
|
||||
|
||||
private void OnException(Exception ex)
|
||||
{
|
||||
VsShellUtilities.ShowMessageBox(
|
||||
this,
|
||||
ex.ToString(),
|
||||
"Razor Error",
|
||||
OLEMSGICON.OLEMSGICON_CRITICAL,
|
||||
OLEMSGBUTTON.OLEMSGBUTTON_OK,
|
||||
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
|
||||
}
|
||||
|
||||
private void Workspace_WorkspaceChanged(object sender, WorkspaceChangeEventArgs e)
|
||||
{
|
||||
switch (e.Kind)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ namespace Microsoft.VisualStudio.RazorExtension.RazorInfo
|
|||
private readonly ITagHelperResolver _tagHelperResolver;
|
||||
private readonly IServiceProvider _services;
|
||||
private readonly Workspace _workspace;
|
||||
private readonly Action<Exception> _errorHandler;
|
||||
|
||||
private DocumentViewModel _currentDocument;
|
||||
private DocumentInfoViewModel _currentDocumentInfo;
|
||||
|
|
@ -40,7 +41,8 @@ namespace Microsoft.VisualStudio.RazorExtension.RazorInfo
|
|||
IRazorEngineAssemblyResolver assemblyResolver,
|
||||
IRazorEngineDirectiveResolver directiveResolver,
|
||||
ITagHelperResolver tagHelperResolver,
|
||||
IRazorEngineDocumentGenerator documentGenerator)
|
||||
IRazorEngineDocumentGenerator documentGenerator,
|
||||
Action<Exception> errorHandler)
|
||||
{
|
||||
_services = services;
|
||||
_workspace = workspace;
|
||||
|
|
@ -48,6 +50,7 @@ namespace Microsoft.VisualStudio.RazorExtension.RazorInfo
|
|||
_directiveResolver = directiveResolver;
|
||||
_tagHelperResolver = tagHelperResolver;
|
||||
_documentGenerator = documentGenerator;
|
||||
_errorHandler = errorHandler;
|
||||
|
||||
GenerateCommand = new RelayCommand<object>(ExecuteGenerate, CanExecuteGenerate);
|
||||
LoadCommand = new RelayCommand<object>(ExecuteLoad, CanExecuteLoad);
|
||||
|
|
@ -180,7 +183,7 @@ namespace Microsoft.VisualStudio.RazorExtension.RazorInfo
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
_errorHandler.Invoke(ex);
|
||||
}
|
||||
|
||||
IsLoading = false;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
<Asset Type="Microsoft.ServiceHub.Service" d:Source="File" Path="razorLanguageService.servicehub.service.json" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.AspNetCore.Razor.Evolution.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.MefComponent" Path="Microsoft.AspNetCore.Razor.Evolution.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.CodeAnalysis.Razor.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.MefComponent" Path="Microsoft.CodeAnalysis.Razor.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.CodeAnalysis.Razor.Workspaces.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.MefComponent" Path="Microsoft.CodeAnalysis.Razor.Workspaces.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.CodeAnalysis.Remote.Razor.dll" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue