feat: add user-based ticket endpoints
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MinimumVisualStudioVersion>17.0</MinimumVisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectTypeGuids>{82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<ProjectGuid>{50F8DCAA-48B9-47D5-ABB8-F8D33BEF1BD1}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Matrix42.Extensions.Scaffolder.Vsix</RootNamespace>
|
||||
<AssemblyName>Matrix42.Extensions.Scaffolder.Vsix</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<GeneratePkgDefFile>true</GeneratePkgDefFile>
|
||||
<UseCodebase>true</UseCodebase>
|
||||
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
|
||||
<IncludeDebugSymbolsInVSIXContainer>false</IncludeDebugSymbolsInVSIXContainer>
|
||||
<IncludeDebugSymbolsInLocalVSIXDeployment>false</IncludeDebugSymbolsInLocalVSIXDeployment>
|
||||
<CopyBuildOutputToOutputDirectory>true</CopyBuildOutputToOutputDirectory>
|
||||
<CopyOutputSymbolsToOutputDirectory>true</CopyOutputSymbolsToOutputDirectory>
|
||||
<StartAction>Program</StartAction>
|
||||
<StartProgram Condition="'$(DevEnvDir)' != ''">$(DevEnvDir)devenv.exe</StartProgram>
|
||||
<StartArguments>/rootsuffix Exp</StartArguments>
|
||||
<GeneratePkgDefFile>false</GeneratePkgDefFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Wizard\ExtensionProjectsWizard.cs" />
|
||||
<Compile Include="Wizard\ProjectDefinition.cs" />
|
||||
<Compile Include="Wizard\RuntimeTargets.cs" />
|
||||
<Compile Include="Wizard\WizardForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Wizard\WizardForm.Designer.cs">
|
||||
<DependentUpon>WizardForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ProjectTemplates\Directory.Build.props.template" />
|
||||
<None Include="ProjectTemplates\Placeholder.csproj" />
|
||||
<None Include="source.extension.vsixmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="17.0.32112.339" ExcludeAssets="runtime" NoWarn="NU1604" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.TemplateWizardInterface">
|
||||
<Version>17.10.40170</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="17.14.2096" NoWarn="NU1604" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="ProjectTemplates\ExtensionSolution.vstemplate" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.36310.24 d17.14
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Matrix42.Extensions.Scaffolder.Vsix", "Matrix42.Extensions.Scaffolder.Vsix.csproj", "{50F8DCAA-48B9-47D5-ABB8-F8D33BEF1BD1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|arm64 = Debug|arm64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|arm64 = Release|arm64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{50F8DCAA-48B9-47D5-ABB8-F8D33BEF1BD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{50F8DCAA-48B9-47D5-ABB8-F8D33BEF1BD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{50F8DCAA-48B9-47D5-ABB8-F8D33BEF1BD1}.Debug|arm64.ActiveCfg = Debug|arm64
|
||||
{50F8DCAA-48B9-47D5-ABB8-F8D33BEF1BD1}.Debug|arm64.Build.0 = Debug|arm64
|
||||
{50F8DCAA-48B9-47D5-ABB8-F8D33BEF1BD1}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{50F8DCAA-48B9-47D5-ABB8-F8D33BEF1BD1}.Debug|x86.Build.0 = Debug|x86
|
||||
{50F8DCAA-48B9-47D5-ABB8-F8D33BEF1BD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{50F8DCAA-48B9-47D5-ABB8-F8D33BEF1BD1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{50F8DCAA-48B9-47D5-ABB8-F8D33BEF1BD1}.Release|arm64.ActiveCfg = Release|arm64
|
||||
{50F8DCAA-48B9-47D5-ABB8-F8D33BEF1BD1}.Release|arm64.Build.0 = Release|arm64
|
||||
{50F8DCAA-48B9-47D5-ABB8-F8D33BEF1BD1}.Release|x86.ActiveCfg = Release|x86
|
||||
{50F8DCAA-48B9-47D5-ABB8-F8D33BEF1BD1}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {ECBF8D8B-3FBE-4CDA-BE52-C37D76054B09}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,7 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,21 @@
|
||||
<VSTemplate Version="3.0.0" Type="Project">
|
||||
<TemplateData>
|
||||
<Name>Matrix42 Extension Solution</Name>
|
||||
<Description>Create a new Matrix42 extension solution (WebApi / Contracts / BizLogic / Custom) using Matrix42.Extensions.SDK.</Description>
|
||||
<ProjectType>CSharp</ProjectType>
|
||||
<SortOrder>1000</SortOrder>
|
||||
<DefaultName>Matrix42.Extension</DefaultName>
|
||||
<CreateNewFolder>true</CreateNewFolder>
|
||||
<ProvideDefaultName>true</ProvideDefaultName>
|
||||
<LocationField>Enabled</LocationField>
|
||||
</TemplateData>
|
||||
|
||||
<TemplateContent>
|
||||
<Project File="Placeholder.csproj" ReplaceParameters="true" TargetFileName="$safeprojectname$.csproj" />
|
||||
</TemplateContent>
|
||||
|
||||
<WizardExtension>
|
||||
<Assembly>Matrix42.Extensions.Scaffolder.Vsix, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</Assembly>
|
||||
<FullClassName>Matrix42.Extensions.Scaffolder.Wizard.ExtensionProjectsWizard</FullClassName>
|
||||
</WizardExtension>
|
||||
</VSTemplate>
|
||||
@@ -0,0 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<OutputType>Library</OutputType>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Matrix42.Extensions.Scaffolder.Vsix")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Matrix42.Extensions.Scaffolder.Vsix")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,231 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using EnvDTE;
|
||||
using EnvDTE80;
|
||||
using Microsoft.VisualStudio.TemplateWizard;
|
||||
|
||||
namespace Matrix42.Extensions.Scaffolder.Wizard
|
||||
{
|
||||
public class ExtensionProjectsWizard : IWizard
|
||||
{
|
||||
private DTE2 _dte;
|
||||
private Project _placeholderProject;
|
||||
private string _extensionNamespace = string.Empty;
|
||||
private List<ProjectDefinition> _projects = new List<ProjectDefinition>();
|
||||
private string _solutionDirectory = string.Empty;
|
||||
|
||||
public void RunStarted(
|
||||
object automationObject,
|
||||
Dictionary<string, string> replacementsDictionary,
|
||||
WizardRunKind runKind,
|
||||
object[] customParams)
|
||||
{
|
||||
_dte = automationObject as DTE2
|
||||
?? throw new InvalidOperationException("DTE2 not available.");
|
||||
|
||||
using (var form = new WizardForm())
|
||||
{
|
||||
var result = form.ShowDialog();
|
||||
if (result != System.Windows.Forms.DialogResult.OK)
|
||||
throw new WizardBackoutException();
|
||||
|
||||
_extensionNamespace = form.ExtensionNamespace;
|
||||
_projects = new List<ProjectDefinition>(form.Projects);
|
||||
}
|
||||
}
|
||||
|
||||
// 🔹 This is the method that was missing
|
||||
public void BeforeOpeningFile(ProjectItem projectItem)
|
||||
{
|
||||
// We don't need to do anything before a file is opened.
|
||||
// Leave empty on purpose.
|
||||
}
|
||||
|
||||
public void ProjectFinishedGenerating(Project project)
|
||||
{
|
||||
_placeholderProject = project;
|
||||
}
|
||||
|
||||
public void ProjectItemFinishedGenerating(ProjectItem projectItem)
|
||||
{
|
||||
}
|
||||
|
||||
public void RunFinished()
|
||||
{
|
||||
var solution = _dte.Solution;
|
||||
_solutionDirectory = Path.GetDirectoryName(solution.FullName);
|
||||
|
||||
if (string.IsNullOrEmpty(_solutionDirectory))
|
||||
return;
|
||||
|
||||
// Remove placeholder project from solution and disk
|
||||
if (_placeholderProject != null)
|
||||
{
|
||||
var placeholderPath = _placeholderProject.FullName;
|
||||
solution.Remove(_placeholderProject);
|
||||
TryDeleteDirectorySafe(Path.GetDirectoryName(placeholderPath));
|
||||
}
|
||||
|
||||
// Drop Directory.Build.props
|
||||
var propsTemplatePath = Path.Combine(
|
||||
GetExtensionInstallPath(),
|
||||
"ProjectTemplates",
|
||||
"Directory.Build.props.template");
|
||||
|
||||
if (File.Exists(propsTemplatePath))
|
||||
{
|
||||
var destProps = Path.Combine(_solutionDirectory, "Directory.Build.props");
|
||||
if (!File.Exists(destProps))
|
||||
File.Copy(propsTemplatePath, destProps, overwrite: false);
|
||||
}
|
||||
|
||||
foreach (var proj in _projects)
|
||||
{
|
||||
CreateProjectFromDefinition(solution, proj);
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShouldAddProjectItem(string filePath) => true;
|
||||
|
||||
private void CreateProjectFromDefinition(Solution solution, ProjectDefinition def)
|
||||
{
|
||||
var projectName = def.GetProjectName(_extensionNamespace);
|
||||
var projectNamespace = def.GetNamespace(_extensionNamespace);
|
||||
var projectDir = Path.Combine(_solutionDirectory, projectName);
|
||||
|
||||
Directory.CreateDirectory(projectDir);
|
||||
|
||||
var csprojPath = Path.Combine(projectDir, projectName + ".csproj");
|
||||
var runtimeIds = def.GetRuntimeIdentifiers();
|
||||
var tfm = "net8.0"; // default target framework
|
||||
|
||||
var csprojContent = GenerateCsproj(def.Type, tfm, runtimeIds, projectNamespace);
|
||||
File.WriteAllText(csprojPath, csprojContent);
|
||||
|
||||
var codeFilePath = Path.Combine(
|
||||
projectDir,
|
||||
def.Type == ProjectType.WebApi ? "Program.cs" : "Class1.cs");
|
||||
|
||||
var codeContent = GenerateCodeFile(def.Type, projectNamespace);
|
||||
File.WriteAllText(codeFilePath, codeContent);
|
||||
|
||||
solution.AddFromFile(csprojPath);
|
||||
}
|
||||
|
||||
private string GenerateCsproj(
|
||||
ProjectType type,
|
||||
string tfm,
|
||||
string runtimeIds,
|
||||
string rootNamespace)
|
||||
{
|
||||
var outputType = type == ProjectType.WebApi ? "Exe" : "Library";
|
||||
var sdk = type == ProjectType.WebApi ? "Microsoft.NET.Sdk.Web" : "Microsoft.NET.Sdk";
|
||||
|
||||
var ridBlock = string.IsNullOrWhiteSpace(runtimeIds)
|
||||
? string.Empty
|
||||
: $" <RuntimeIdentifiers>{runtimeIds}</RuntimeIdentifiers>{Environment.NewLine}";
|
||||
|
||||
return
|
||||
$@"<Project Sdk=""{sdk}"">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>{tfm}</TargetFramework>
|
||||
<OutputType>{outputType}</OutputType>
|
||||
<RootNamespace>{rootNamespace}</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
{ridBlock} </PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include=""Matrix42.Extensions.SDK"" Version=""1.0.0"" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
";
|
||||
}
|
||||
|
||||
private string GenerateCodeFile(ProjectType type, string ns)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case ProjectType.WebApi:
|
||||
return
|
||||
$@"using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Matrix42.Extensions.SDK;
|
||||
|
||||
namespace {ns}
|
||||
{{
|
||||
public class Program
|
||||
{{
|
||||
public static void Main(string[] args)
|
||||
{{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// TODO: configure Matrix42.Extensions.SDK services
|
||||
|
||||
var app = builder.Build();
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
}}
|
||||
}}
|
||||
}}";
|
||||
case ProjectType.Contracts:
|
||||
return
|
||||
$@"namespace {ns}
|
||||
{{
|
||||
// Place your contracts (DTOs, interfaces) here
|
||||
public class SampleContract
|
||||
{{
|
||||
public string Id {{ get; set; }} = string.Empty;
|
||||
}}
|
||||
}}";
|
||||
case ProjectType.BizLogic:
|
||||
return
|
||||
$@"using Matrix42.Extensions.SDK;
|
||||
|
||||
namespace {ns}
|
||||
{{
|
||||
// Place your business logic services here
|
||||
public class SampleService
|
||||
{{
|
||||
public string SayHello() => ""Hello from {ns}"";
|
||||
}}
|
||||
}}";
|
||||
case ProjectType.Custom:
|
||||
default:
|
||||
return
|
||||
$@"namespace {ns}
|
||||
{{
|
||||
// Custom project for your extension
|
||||
public class CustomEntry
|
||||
{{
|
||||
public string Name {{ get; set; }} = ""Custom"";
|
||||
}}
|
||||
}}";
|
||||
}
|
||||
}
|
||||
|
||||
private string GetExtensionInstallPath()
|
||||
{
|
||||
var asmPath = typeof(ExtensionProjectsWizard).Assembly.Location;
|
||||
return Path.GetDirectoryName(asmPath);
|
||||
}
|
||||
|
||||
private void TryDeleteDirectorySafe(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(path) && Directory.Exists(path))
|
||||
Directory.Delete(path, recursive: true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Matrix42.Extensions.Scaffolder.Wizard
|
||||
{
|
||||
public enum ProjectType
|
||||
{
|
||||
WebApi,
|
||||
Contracts,
|
||||
BizLogic,
|
||||
Custom
|
||||
}
|
||||
|
||||
public class ProjectDefinition
|
||||
{
|
||||
public ProjectType Type { get; set; }
|
||||
public string Prefix { get; set; } = string.Empty; // custom for Custom type, otherwise derived
|
||||
public RuntimeTargets Runtimes { get; set; }
|
||||
|
||||
public string EffectivePrefix
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Type == ProjectType.Custom)
|
||||
return Prefix;
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case ProjectType.WebApi:
|
||||
return string.IsNullOrWhiteSpace(Prefix) ? "Services" : Prefix;
|
||||
case ProjectType.Contracts:
|
||||
return string.IsNullOrWhiteSpace(Prefix) ? "Contracts" : Prefix;
|
||||
case ProjectType.BizLogic:
|
||||
return string.IsNullOrWhiteSpace(Prefix) ? "BizLogic" : Prefix;
|
||||
default:
|
||||
return Prefix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Display => $"{Type} - Prefix: {EffectivePrefix} - Runtimes: {Runtimes}";
|
||||
|
||||
public string GetProjectName(string extensionNamespace)
|
||||
{
|
||||
var pfx = EffectivePrefix?.Trim();
|
||||
return string.IsNullOrWhiteSpace(pfx)
|
||||
? extensionNamespace
|
||||
: $"{extensionNamespace}.{pfx}";
|
||||
}
|
||||
|
||||
public string GetNamespace(string extensionNamespace) => GetProjectName(extensionNamespace);
|
||||
|
||||
public string GetRuntimeIdentifiers()
|
||||
{
|
||||
if (Runtimes.HasFlag(RuntimeTargets.All))
|
||||
return "win-x64;linux-x64";
|
||||
|
||||
var list = new List<string>();
|
||||
if (Runtimes.HasFlag(RuntimeTargets.Win) || Runtimes.HasFlag(RuntimeTargets.WinCore))
|
||||
list.Add("win-x64");
|
||||
if (Runtimes.HasFlag(RuntimeTargets.LinuxCore))
|
||||
list.Add("linux-x64");
|
||||
|
||||
return string.Join(";", list);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Matrix42.Extensions.Scaffolder.Wizard
|
||||
{
|
||||
[System.Flags]
|
||||
public enum RuntimeTargets
|
||||
{
|
||||
None = 0,
|
||||
Win = 1,
|
||||
WinCore = 2,
|
||||
LinuxCore = 4,
|
||||
All = 8
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
namespace Matrix42.Extensions.Scaffolder.Wizard
|
||||
{
|
||||
partial class WizardForm
|
||||
{
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
private System.Windows.Forms.Label lblTitle;
|
||||
private System.Windows.Forms.Label lblExtensionNamespace;
|
||||
private System.Windows.Forms.TextBox txtExtensionNamespace;
|
||||
private System.Windows.Forms.Label lblHint;
|
||||
private System.Windows.Forms.Label lblAddProjects;
|
||||
private System.Windows.Forms.Label lblProjectType;
|
||||
private System.Windows.Forms.ComboBox cboProjectType;
|
||||
private System.Windows.Forms.Label lblProjectPrefix;
|
||||
private System.Windows.Forms.TextBox txtProjectPrefix;
|
||||
private System.Windows.Forms.Label lblRuntimes;
|
||||
private System.Windows.Forms.CheckedListBox clbRuntimes;
|
||||
private System.Windows.Forms.Button btnAddProject;
|
||||
private System.Windows.Forms.ListBox lstProjects;
|
||||
private System.Windows.Forms.Button btnRemoveSelected;
|
||||
private System.Windows.Forms.Button btnOK;
|
||||
private System.Windows.Forms.Button btnCancel;
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
components.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.lblTitle = new System.Windows.Forms.Label();
|
||||
this.lblExtensionNamespace = new System.Windows.Forms.Label();
|
||||
this.txtExtensionNamespace = new System.Windows.Forms.TextBox();
|
||||
this.lblHint = new System.Windows.Forms.Label();
|
||||
this.lblAddProjects = new System.Windows.Forms.Label();
|
||||
this.lblProjectType = new System.Windows.Forms.Label();
|
||||
this.cboProjectType = new System.Windows.Forms.ComboBox();
|
||||
this.lblProjectPrefix = new System.Windows.Forms.Label();
|
||||
this.txtProjectPrefix = new System.Windows.Forms.TextBox();
|
||||
this.lblRuntimes = new System.Windows.Forms.Label();
|
||||
this.clbRuntimes = new System.Windows.Forms.CheckedListBox();
|
||||
this.btnAddProject = new System.Windows.Forms.Button();
|
||||
this.lstProjects = new System.Windows.Forms.ListBox();
|
||||
this.btnRemoveSelected = new System.Windows.Forms.Button();
|
||||
this.btnOK = new System.Windows.Forms.Button();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lblTitle
|
||||
//
|
||||
this.lblTitle.AutoSize = true;
|
||||
this.lblTitle.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Bold);
|
||||
this.lblTitle.Location = new System.Drawing.Point(12, 9);
|
||||
this.lblTitle.Name = "lblTitle";
|
||||
this.lblTitle.Size = new System.Drawing.Size(120, 20);
|
||||
this.lblTitle.TabIndex = 0;
|
||||
this.lblTitle.Text = "Projects Wizard";
|
||||
//
|
||||
// lblExtensionNamespace
|
||||
//
|
||||
this.lblExtensionNamespace.AutoSize = true;
|
||||
this.lblExtensionNamespace.Location = new System.Drawing.Point(13, 44);
|
||||
this.lblExtensionNamespace.Name = "lblExtensionNamespace";
|
||||
this.lblExtensionNamespace.Size = new System.Drawing.Size(113, 15);
|
||||
this.lblExtensionNamespace.TabIndex = 1;
|
||||
this.lblExtensionNamespace.Text = "Extension Namespace";
|
||||
//
|
||||
// txtExtensionNamespace
|
||||
//
|
||||
this.txtExtensionNamespace.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtExtensionNamespace.Location = new System.Drawing.Point(16, 62);
|
||||
this.txtExtensionNamespace.Name = "txtExtensionNamespace";
|
||||
this.txtExtensionNamespace.Size = new System.Drawing.Size(444, 23);
|
||||
this.txtExtensionNamespace.TabIndex = 2;
|
||||
//
|
||||
// lblHint
|
||||
//
|
||||
this.lblHint.AutoSize = true;
|
||||
this.lblHint.Location = new System.Drawing.Point(466, 65);
|
||||
this.lblHint.Name = "lblHint";
|
||||
this.lblHint.Size = new System.Drawing.Size(121, 15);
|
||||
this.lblHint.TabIndex = 3;
|
||||
this.lblHint.Text = "aka Matrix42.MyExtension";
|
||||
//
|
||||
// lblAddProjects
|
||||
//
|
||||
this.lblAddProjects.AutoSize = true;
|
||||
this.lblAddProjects.Location = new System.Drawing.Point(13, 103);
|
||||
this.lblAddProjects.Name = "lblAddProjects";
|
||||
this.lblAddProjects.Size = new System.Drawing.Size(71, 15);
|
||||
this.lblAddProjects.TabIndex = 4;
|
||||
this.lblAddProjects.Text = "Add Projects";
|
||||
//
|
||||
// lblProjectType
|
||||
//
|
||||
this.lblProjectType.AutoSize = true;
|
||||
this.lblProjectType.Location = new System.Drawing.Point(13, 129);
|
||||
this.lblProjectType.Name = "lblProjectType";
|
||||
this.lblProjectType.Size = new System.Drawing.Size(70, 15);
|
||||
this.lblProjectType.TabIndex = 5;
|
||||
this.lblProjectType.Text = "Project Type";
|
||||
//
|
||||
// cboProjectType
|
||||
//
|
||||
this.cboProjectType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cboProjectType.FormattingEnabled = true;
|
||||
this.cboProjectType.Location = new System.Drawing.Point(16, 147);
|
||||
this.cboProjectType.Name = "cboProjectType";
|
||||
this.cboProjectType.Size = new System.Drawing.Size(150, 23);
|
||||
this.cboProjectType.TabIndex = 6;
|
||||
//
|
||||
// lblProjectPrefix
|
||||
//
|
||||
this.lblProjectPrefix.AutoSize = true;
|
||||
this.lblProjectPrefix.Location = new System.Drawing.Point(179, 129);
|
||||
this.lblProjectPrefix.Name = "lblProjectPrefix";
|
||||
this.lblProjectPrefix.Size = new System.Drawing.Size(75, 15);
|
||||
this.lblProjectPrefix.TabIndex = 7;
|
||||
this.lblProjectPrefix.Text = "Project Prefix";
|
||||
//
|
||||
// txtProjectPrefix
|
||||
//
|
||||
this.txtProjectPrefix.Location = new System.Drawing.Point(182, 147);
|
||||
this.txtProjectPrefix.Name = "txtProjectPrefix";
|
||||
this.txtProjectPrefix.Size = new System.Drawing.Size(150, 23);
|
||||
this.txtProjectPrefix.TabIndex = 8;
|
||||
//
|
||||
// lblRuntimes
|
||||
//
|
||||
this.lblRuntimes.AutoSize = true;
|
||||
this.lblRuntimes.Location = new System.Drawing.Point(345, 129);
|
||||
this.lblRuntimes.Name = "lblRuntimes";
|
||||
this.lblRuntimes.Size = new System.Drawing.Size(121, 15);
|
||||
this.lblRuntimes.TabIndex = 9;
|
||||
this.lblRuntimes.Text = "Runtimes (multiselect)";
|
||||
//
|
||||
// clbRuntimes
|
||||
//
|
||||
this.clbRuntimes.CheckOnClick = true;
|
||||
this.clbRuntimes.FormattingEnabled = true;
|
||||
this.clbRuntimes.Location = new System.Drawing.Point(348, 147);
|
||||
this.clbRuntimes.Name = "clbRuntimes";
|
||||
this.clbRuntimes.Size = new System.Drawing.Size(150, 76);
|
||||
this.clbRuntimes.TabIndex = 10;
|
||||
//
|
||||
// btnAddProject
|
||||
//
|
||||
this.btnAddProject.Location = new System.Drawing.Point(504, 147);
|
||||
this.btnAddProject.Name = "btnAddProject";
|
||||
this.btnAddProject.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnAddProject.TabIndex = 11;
|
||||
this.btnAddProject.Text = "Add";
|
||||
this.btnAddProject.UseVisualStyleBackColor = true;
|
||||
this.btnAddProject.Click += new System.EventHandler(this.btnAddProject_Click);
|
||||
//
|
||||
// lstProjects
|
||||
//
|
||||
this.lstProjects.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lstProjects.FormattingEnabled = true;
|
||||
this.lstProjects.ItemHeight = 15;
|
||||
this.lstProjects.Location = new System.Drawing.Point(16, 236);
|
||||
this.lstProjects.Name = "lstProjects";
|
||||
this.lstProjects.Size = new System.Drawing.Size(563, 139);
|
||||
this.lstProjects.TabIndex = 12;
|
||||
//
|
||||
// btnRemoveSelected
|
||||
//
|
||||
this.btnRemoveSelected.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.btnRemoveSelected.Location = new System.Drawing.Point(16, 385);
|
||||
this.btnRemoveSelected.Name = "btnRemoveSelected";
|
||||
this.btnRemoveSelected.Size = new System.Drawing.Size(120, 23);
|
||||
this.btnRemoveSelected.TabIndex = 13;
|
||||
this.btnRemoveSelected.Text = "Remove selected";
|
||||
this.btnRemoveSelected.UseVisualStyleBackColor = true;
|
||||
this.btnRemoveSelected.Click += new System.EventHandler(this.btnRemoveSelected_Click);
|
||||
//
|
||||
// btnOK
|
||||
//
|
||||
this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnOK.Location = new System.Drawing.Point(423, 385);
|
||||
this.btnOK.Name = "btnOK";
|
||||
this.btnOK.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnOK.TabIndex = 14;
|
||||
this.btnOK.Text = "Create";
|
||||
this.btnOK.UseVisualStyleBackColor = true;
|
||||
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnCancel.Location = new System.Drawing.Point(504, 385);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnCancel.TabIndex = 15;
|
||||
this.btnCancel.Text = "Cancel";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||
//
|
||||
// WizardForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(592, 420);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.Controls.Add(this.btnOK);
|
||||
this.Controls.Add(this.btnRemoveSelected);
|
||||
this.Controls.Add(this.lstProjects);
|
||||
this.Controls.Add(this.btnAddProject);
|
||||
this.Controls.Add(this.clbRuntimes);
|
||||
this.Controls.Add(this.lblRuntimes);
|
||||
this.Controls.Add(this.txtProjectPrefix);
|
||||
this.Controls.Add(this.lblProjectPrefix);
|
||||
this.Controls.Add(this.cboProjectType);
|
||||
this.Controls.Add(this.lblProjectType);
|
||||
this.Controls.Add(this.lblAddProjects);
|
||||
this.Controls.Add(this.lblHint);
|
||||
this.Controls.Add(this.txtExtensionNamespace);
|
||||
this.Controls.Add(this.lblExtensionNamespace);
|
||||
this.Controls.Add(this.lblTitle);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "WizardForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Matrix42 Extension Solution Wizard";
|
||||
this.Load += new System.EventHandler(this.WizardForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Matrix42.Extensions.Scaffolder.Wizard
|
||||
{
|
||||
public partial class WizardForm : Form
|
||||
{
|
||||
private readonly List<ProjectDefinition> _projects = new List<ProjectDefinition>();
|
||||
|
||||
public string ExtensionNamespace => txtExtensionNamespace.Text.Trim();
|
||||
public IReadOnlyList<ProjectDefinition> Projects => _projects;
|
||||
|
||||
public WizardForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
cboProjectType.DataSource = Enum.GetValues(typeof(ProjectType));
|
||||
|
||||
clbRuntimes.Items.Add("Win");
|
||||
clbRuntimes.Items.Add("WinCore");
|
||||
clbRuntimes.Items.Add("LinuxCore");
|
||||
clbRuntimes.Items.Add("ALL");
|
||||
|
||||
cboProjectType.SelectedIndexChanged += CboProjectType_SelectedIndexChanged;
|
||||
}
|
||||
|
||||
private void WizardForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
lblHint.Text = "aka Matrix42.MyExtension";
|
||||
}
|
||||
|
||||
private void CboProjectType_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
var type = (ProjectType)cboProjectType.SelectedItem;
|
||||
switch (type)
|
||||
{
|
||||
case ProjectType.WebApi:
|
||||
txtProjectPrefix.Text = "Services";
|
||||
txtProjectPrefix.ReadOnly = false;
|
||||
break;
|
||||
case ProjectType.Contracts:
|
||||
txtProjectPrefix.Text = "Contracts";
|
||||
txtProjectPrefix.ReadOnly = false;
|
||||
break;
|
||||
case ProjectType.BizLogic:
|
||||
txtProjectPrefix.Text = "BizLogic";
|
||||
txtProjectPrefix.ReadOnly = false;
|
||||
break;
|
||||
case ProjectType.Custom:
|
||||
txtProjectPrefix.Text = string.Empty;
|
||||
txtProjectPrefix.ReadOnly = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void btnAddProject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!ValidateProjectInputs())
|
||||
return;
|
||||
|
||||
var def = new ProjectDefinition
|
||||
{
|
||||
Type = (ProjectType)cboProjectType.SelectedItem,
|
||||
Prefix = txtProjectPrefix.Text.Trim(),
|
||||
Runtimes = GetSelectedRuntimes()
|
||||
};
|
||||
|
||||
_projects.Add(def);
|
||||
lstProjects.Items.Add(def.Display);
|
||||
|
||||
txtProjectPrefix.Clear();
|
||||
for (int i = 0; i < clbRuntimes.Items.Count; i++)
|
||||
clbRuntimes.SetItemChecked(i, false);
|
||||
}
|
||||
|
||||
private RuntimeTargets GetSelectedRuntimes()
|
||||
{
|
||||
RuntimeTargets result = RuntimeTargets.None;
|
||||
|
||||
foreach (var item in clbRuntimes.CheckedItems)
|
||||
{
|
||||
switch (item.ToString())
|
||||
{
|
||||
case "Win":
|
||||
result |= RuntimeTargets.Win;
|
||||
break;
|
||||
case "WinCore":
|
||||
result |= RuntimeTargets.WinCore;
|
||||
break;
|
||||
case "LinuxCore":
|
||||
result |= RuntimeTargets.LinuxCore;
|
||||
break;
|
||||
case "ALL":
|
||||
result |= RuntimeTargets.All;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private bool ValidateProjectInputs()
|
||||
{
|
||||
if (cboProjectType.SelectedItem == null)
|
||||
{
|
||||
MessageBox.Show("Please select project type.");
|
||||
return false;
|
||||
}
|
||||
|
||||
var type = (ProjectType)cboProjectType.SelectedItem;
|
||||
if (string.IsNullOrWhiteSpace(txtProjectPrefix.Text))
|
||||
{
|
||||
if (type == ProjectType.Custom)
|
||||
{
|
||||
MessageBox.Show("Project prefix is required for Custom project type.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (clbRuntimes.CheckedItems.Count == 0)
|
||||
{
|
||||
MessageBox.Show("Please select at least one runtime.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void btnRemoveSelected_Click(object sender, EventArgs e)
|
||||
{
|
||||
int idx = lstProjects.SelectedIndex;
|
||||
if (idx < 0 || idx >= _projects.Count)
|
||||
return;
|
||||
|
||||
_projects.RemoveAt(idx);
|
||||
lstProjects.Items.RemoveAt(idx);
|
||||
}
|
||||
|
||||
private void btnOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(ExtensionNamespace))
|
||||
{
|
||||
MessageBox.Show("Extension Namespace is required.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_projects.Count == 0)
|
||||
{
|
||||
MessageBox.Show("Please add at least one project.");
|
||||
return;
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
|
||||
<Metadata>
|
||||
<Identity Id="Matrix42.Extensions.Scaffolder.Vsix.7c0f30ed-547f-4e1d-a046-8120ae21fc8b" Version="1.0" Language="en-US" Publisher="Matrix42" />
|
||||
<DisplayName>Matrix42.Extensions.Scaffolder.Vsix</DisplayName>
|
||||
<Description xml:space="preserve">Creates a new Matrix42 extension solution with multiple projects based on Matrix42.Extensions.SDK.</Description>
|
||||
</Metadata>
|
||||
<Installation>
|
||||
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[17.0, 18.0)">
|
||||
<ProductArchitecture>amd64</ProductArchitecture>
|
||||
</InstallationTarget>
|
||||
</Installation>
|
||||
<Dependencies>
|
||||
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.7,)" />
|
||||
</Dependencies>
|
||||
<Prerequisites>
|
||||
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[17.0,18.0)" DisplayName="Visual Studio core editor" />
|
||||
</Prerequisites>
|
||||
<Assets>
|
||||
<Asset Type="Microsoft.VisualStudio.ProjectTemplate" Path="ProjectTemplates\ExtensionSolution.vstemplate" />
|
||||
</Assets>
|
||||
</PackageManifest>
|
||||
Reference in New Issue
Block a user