-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #879 from christianhelle/refitter-settings-file
Add support for .refitter files
- Loading branch information
Showing
8 changed files
with
180 additions
and
9 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions
29
src/Core/ApiClientCodeGen.Core/Exceptions/RunRefitterCommandException.cs
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,29 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Rapicgen.Core.Exceptions | ||
{ | ||
[ExcludeFromCodeCoverage] | ||
[Serializable] | ||
public class RunRefitterCommandException : RapicgenException | ||
{ | ||
public RunRefitterCommandException() | ||
{ | ||
} | ||
|
||
public RunRefitterCommandException(string message) : base(message) | ||
{ | ||
} | ||
|
||
public RunRefitterCommandException(string message, Exception inner) : base(message, inner) | ||
{ | ||
} | ||
|
||
protected RunRefitterCommandException( | ||
SerializationInfo info, | ||
StreamingContext context) : base(info, context) | ||
{ | ||
} | ||
} | ||
} |
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
61 changes: 61 additions & 0 deletions
61
src/VSIX/ApiClientCodeGen.VSIX.Shared/Commands/Refitter/RefitterCommand.cs
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,61 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Threading; | ||
using Rapicgen.Core; | ||
using Rapicgen.Core.Exceptions; | ||
using Rapicgen.Core.Logging; | ||
using Rapicgen.Extensions; | ||
using EnvDTE; | ||
using Microsoft.VisualStudio.Shell; | ||
using Task = System.Threading.Tasks.Task; | ||
using Rapicgen.Core.Generators.Refitter; | ||
|
||
namespace Rapicgen.Commands.Refitter | ||
{ | ||
[ExcludeFromCodeCoverage] | ||
public class RefitterCommand : ICommandInitializer | ||
{ | ||
public const string ContextGuid = "2A5A0DB6-FC9C-48AB-98E5-C69D7157CEF5"; | ||
public const string Name = "Refitter Context"; | ||
public const string Expression = "refitter"; | ||
public const string TermValue = "HierSingleSelectionName:.refitter"; | ||
|
||
protected int CommandId { get; } = 0x200; | ||
protected Guid CommandSet { get; } = new Guid("E00623E7-31F9-40E9-BDEE-9D7829D09184"); | ||
|
||
public Task InitializeAsync(AsyncPackage package, CancellationToken token) | ||
=> package.SetupCommandAsync( | ||
CommandSet, | ||
CommandId, | ||
ExecuteAsync, | ||
token); | ||
|
||
private async Task ExecuteAsync(DTE dte, AsyncPackage package) | ||
{ | ||
try | ||
{ | ||
await OnExecuteAsync(dte, package); | ||
} | ||
catch (Exception e) | ||
{ | ||
throw new RunRefitterCommandException(GetType().Name, e); | ||
} | ||
} | ||
|
||
private static async Task OnExecuteAsync(DTE dte, AsyncPackage package) | ||
{ | ||
Logger.Instance.TrackFeatureUsage("Generate Refitter output"); | ||
|
||
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); | ||
|
||
var item = dte.SelectedItems.Item(1).ProjectItem; | ||
var refitterSettingsFile = item.FileNames[0]; | ||
|
||
var codeGenerator = new RefitterCodeGenerator(refitterSettingsFile, default, default); | ||
codeGenerator.GenerateCode(null); | ||
|
||
var project = dte.GetActiveProject()!; | ||
await project.InstallMissingPackagesAsync(package, SupportedCodeGenerator.Refitter); | ||
} | ||
} | ||
} |
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