-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow loading the AvaloniaVS extension when referencing the Avalonia nuget package or add ProjectCapability Avalonia
- Loading branch information
1 parent
c29121f
commit 7418b6e
Showing
7 changed files
with
47 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
namespace AvaloniaVS; | ||
using System; | ||
|
||
namespace AvaloniaVS; | ||
|
||
internal static class Constants | ||
{ | ||
public const string PackageGuidString = "865ba8d5-1180-4bf8-8821-345f72a4cb79"; | ||
public static readonly Guid PackageGuid = new (PackageGuidString); | ||
public const string PackageName = "Avalonia Xaml Editor"; | ||
public const string axaml = nameof(axaml); | ||
public const string xaml = nameof(xaml); | ||
public const string paml = nameof(paml); | ||
|
||
public const string AvaloviaFactoryEditorGuidString = @"6D5344A2-2FCD-49DE-A09D-6A14FD1B1224"; | ||
public static readonly Guid AvaloviaFactoryEditorGuid = new (AvaloviaFactoryEditorGuidString); | ||
|
||
public const string AvaloniaCapability = nameof(Avalonia); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Microsoft.VisualStudio.ProjectSystem; | ||
using Microsoft.VisualStudio.Shell; | ||
using System.ComponentModel.Composition; | ||
using IAsyncServiceProvider = Microsoft.VisualStudio.Shell.IAsyncServiceProvider; | ||
using Microsoft.VisualStudio.Shell.Interop; | ||
using Task = System.Threading.Tasks.Task; | ||
|
||
namespace AvaloniaVS.ProjectSystem; | ||
|
||
[Export(ExportContractNames.Scopes.UnconfiguredProject, typeof(IProjectDynamicLoadComponent))] | ||
[AppliesTo(Constants.AvaloniaCapability)] | ||
internal class AvaloniaProject : IProjectDynamicLoadComponent | ||
{ | ||
private IAsyncServiceProvider asyncServiceProvider; | ||
|
||
public async Task LoadAsync() | ||
{ | ||
if (asyncServiceProvider is null) | ||
{ | ||
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); | ||
if (ServiceProvider.GlobalProvider.GetService(typeof(IVsShell)) is IVsShell shell) | ||
{ | ||
if (shell.IsPackageLoaded(Constants.PackageGuid, out var vsPackage) | ||
!= Microsoft.VisualStudio.VSConstants.S_OK) | ||
{ | ||
shell.LoadPackage(Constants.PackageGuid, out vsPackage); | ||
} | ||
asyncServiceProvider = (IAsyncServiceProvider)vsPackage; | ||
} | ||
} | ||
} | ||
|
||
public async Task UnloadAsync() | ||
{ | ||
// Unload the feature | ||
await Task.CompletedTask; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters