Skip to content

Commit

Permalink
Start SolidityProjectWizard implementation. Can popup dialog on proje…
Browse files Browse the repository at this point in the history
…ct create.
  • Loading branch information
allisterb committed Sep 14, 2024
1 parent a154930 commit 95ae06e
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/Stratis.VS.SolidityProjectTemplate/Solidity.vstemplate
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@
<ProjectItem ReplaceParameters="false" OpenInEditor="false">SmartContract1.sol</ProjectItem>
</Project>
</TemplateContent>
<WizardExtension>
<Assembly>Stratis.VS.StratisEVM, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null</Assembly>
<FullClassName>Stratis.VS.StratisEVM.WizardImplementation</FullClassName>
</WizardExtension>
</VSTemplate>
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="Ethereum_32x32.png" />
<Content Include="Ethereum_32x32_black.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
Expand Down
66 changes: 66 additions & 0 deletions src/Stratis.VS.StratisEVM/BaseWizard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TemplateWizard;
using System.Windows.Forms;
using EnvDTE;

namespace Stratis.VS.StratisEVM
{
public class WizardImplementation : IWizard
{
private SolidityProjectWizardUserInputForm inputForm;
private string customMessage;

// This method is called before opening any item that
// has the OpenInEditor attribute.
public void BeforeOpeningFile(ProjectItem projectItem)
{
}

public void ProjectFinishedGenerating(Project project)
{
}

// This method is only called for item templates,
// not for project templates.
public void ProjectItemFinishedGenerating(ProjectItem
projectItem)
{
}

// This method is called after the project is created.
public void RunFinished()
{
}

public void RunStarted(object automationObject,
Dictionary<string, string> replacementsDictionary,
WizardRunKind runKind, object[] customParams)
{
try
{
// Display a form to the user. The form collects
// input for the custom message.
inputForm = new SolidityProjectWizardUserInputForm();
inputForm.ShowDialog();

customMessage = SolidityProjectWizardUserInputForm.CustomMessage;

// Add custom parameters.
replacementsDictionary.Add("$custommessage$",
customMessage);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}

// This method is only called for item templates,
// not for project templates.
public bool ShouldAddProjectItem(string filePath)
{
return true;
}
}
}
44 changes: 44 additions & 0 deletions src/Stratis.VS.StratisEVM/SolidityProjectWizardUserInputForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System.Windows.Forms;
using System;

namespace Stratis.VS.StratisEVM
{
public partial class SolidityProjectWizardUserInputForm : Form
{
private static string customMessage;
private TextBox textBox1;
private Button button1;

public SolidityProjectWizardUserInputForm()
{
this.Size = new System.Drawing.Size(155, 265);

button1 = new Button();
button1.Location = new System.Drawing.Point(90, 25);
button1.Size = new System.Drawing.Size(50, 25);
button1.Click += button1_Click;
this.Controls.Add(button1);

textBox1 = new TextBox();
textBox1.Location = new System.Drawing.Point(10, 25);
textBox1.Size = new System.Drawing.Size(70, 20);
this.Controls.Add(textBox1);
}
public static string CustomMessage
{
get
{
return customMessage;
}
set
{
customMessage = value;
}
}
private void button1_Click(object sender, EventArgs e)
{
customMessage = textBox1.Text;
this.Close();
}
}
}
12 changes: 9 additions & 3 deletions src/Stratis.VS.StratisEVM/Stratis.VS.StratisEVM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="BaseWizard.cs" />
<Compile Include="SolidityConfiguredProject.cs" />
<Compile Include="SolidityProjectWizardUserInputForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SolidityUnconfiguredProject.cs" />
<Compile Include="SolidityProjectProperties.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down Expand Up @@ -91,6 +95,8 @@
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.LanguageServer.Client">
Expand All @@ -103,6 +109,9 @@
<Version>17.9.380</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="17.0.32112.339" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.VisualStudio.TemplateWizardInterface">
<Version>17.5.33428.366</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Workspace">
<Version>17.1.11-preview-0002</Version>
</PackageReference>
Expand Down Expand Up @@ -165,17 +174,14 @@
These are the parts of the custom project system which will be deployed as part of the
final implementation, and provide the basic processing for handling rules in CPS.
-->

<!--
The XAML files provide buth compile-time implementations for CPS rules as well as
runtime information for property pages. They will also be deployed as part of the
final package.
-->

<!-- TODO: This copies the build authoring to a well-known location so that on the machine this project builds on,
the projects created by the 3rd party consumer can open and build. But the real 3rd party consumer will not
have run this step so they won't be able to open their projects.
To ship, the project type author must create an MSI that places these files in a well-known location on the
customer machine and update the project template to point at that location.-->

</Project>
1 change: 1 addition & 0 deletions src/Stratis.VS.StratisEVM/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="File" Path="SolidityLanguageSettings.pkgdef" />
<Asset Type="Microsoft.VisualStudio.ProjectTemplate" d:Source="Project" d:ProjectName="Stratis.VS.SolidityProjectTemplate" d:TargetPath="|Stratis.VS.SolidityProjectTemplate;TemplateProjectOutputGroup|" Path="ProjectTemplates" d:VsixSubPath="ProjectTemplates" />
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="File" Path="template.pkgdef" />
<Asset Type="Microsoft.VisualStudio.Assembly" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%|" AssemblyName="|%CurrentProject%;AssemblyName|" />
</Assets>
</PackageManifest>

0 comments on commit 95ae06e

Please sign in to comment.