Skip to content

Commit

Permalink
Enhancements to VS plugin
Browse files Browse the repository at this point in the history
Visual studio styling better
Element attribute and route generation inside aurelia project
  • Loading branch information
brandonseydel committed Mar 8, 2019
1 parent e7e415c commit 30ba6fa
Show file tree
Hide file tree
Showing 47 changed files with 806 additions and 512 deletions.
28 changes: 25 additions & 3 deletions Aurelia.DotNet.Extensions/Util/StringHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
Expand All @@ -9,9 +10,30 @@ namespace Aurelia.DotNet.Extensions
{
public static class StringHelpers
{
public static string ToPascalCase(this string stringToConvert) => string.Concat(stringToConvert?.Split(new[] { '-', '_' }, StringSplitOptions.RemoveEmptyEntries)
.Select(word => word.Substring(0, 1).ToUpper() +
word.Substring(1).ToLower()));
public static string ToPascalCase(this string original)
{
Regex invalidCharsRgx = new Regex("[^_a-zA-Z0-9]");
Regex whiteSpace = new Regex(@"(?<=\s)");
Regex startsWithLowerCaseChar = new Regex("^[a-z]");
Regex firstCharFollowedByUpperCasesOnly = new Regex("(?<=[A-Z])[A-Z0-9]+$");
Regex lowerCaseNextToNumber = new Regex("(?<=[0-9])[a-z]");
Regex upperCaseInside = new Regex("(?<=[A-Z])[A-Z]+?((?=[A-Z][a-z])|(?=[0-9]))");

// replace white spaces with undescore, then replace all invalid chars with empty string
var pascalCase = invalidCharsRgx.Replace(whiteSpace.Replace(original, "_"), string.Empty)
// split by underscores
.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries)
// set first letter to uppercase
.Select(w => startsWithLowerCaseChar.Replace(w, m => m.Value.ToUpper()))
// replace second and all following upper case letters to lower if there is no next lower (ABC -> Abc)
.Select(w => firstCharFollowedByUpperCasesOnly.Replace(w, m => m.Value.ToLower()))
// set upper case the first lower case following a number (Ab9cd -> Ab9Cd)
.Select(w => lowerCaseNextToNumber.Replace(w, m => m.Value.ToUpper()))
// lower second and next upper case letters except the last if it follows by any lower (ABcDEf -> AbcDef)
.Select(w => upperCaseInside.Replace(w, m => m.Value.ToLower()));

return string.Concat(pascalCase);
}

public static string ToCamelCase(this string stringToConvert) => stringToConvert?.ToPascalCase()?.LowerCaseFirstLetter();

Expand Down
16 changes: 7 additions & 9 deletions Aurelia.DotNet.VSIX/Aurelia.DotNet.VSIX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Commands\AureliaCommands.cs" />
<Compile Include="Commands\CreateAurelia\Command1.cs" />
<Compile Include="Commands\GenerateElement\GenerateElement.cs" />
<Compile Include="Commands\UpdateAurelia\UpdateAureliaCommand.cs" />
<Compile Include="Commands\GenerateAttribute.cs" />
<Compile Include="Commands\GenerateRoute.cs" />
<Compile Include="Commands\GenerateElement.cs" />
<Compile Include="Date.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Helpers\Aurelia.cs" />
Expand All @@ -79,6 +79,8 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="Templates\Attribute\attribute.js.txt" />
<Content Include="Templates\Attribute\attribute.ts.txt" />
<Content Include="Templates\Element\element.both.html.txt">
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
Expand All @@ -100,9 +102,6 @@
<None Include="key.snk">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="Commands\CreateAurelia\Resources\Command1.png" />
<Content Include="Commands\GenerateElement\Resources\GenerateElement.png" />
<Content Include="Commands\UpdateAurelia\Resources\UpdateAureliaCommand.png" />
<Content Include="Newtonsoft.Json.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
Expand Down Expand Up @@ -175,15 +174,14 @@
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<IncludeOutputGroupsInVSIX>TemplateProjectOutputGroup%3b</IncludeOutputGroupsInVSIX>
</ProjectReference>
<ProjectReference Include="..\Aurelia.Dotnet.Wizard\Aurelia.Dotnet.Wizard.csproj">
<ProjectReference Include="..\Aurelia.Dotnet.Wizard\Aurelia.DotNet.Wizard.csproj">
<Project>{16B94BF4-1F00-4C4C-BDA9-9D074A532D83}</Project>
<Name>Aurelia.Dotnet.Wizard</Name>
<Name>Aurelia.DotNet.Wizard</Name>
<IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup%3bBuiltProjectOutputGroupDependencies%3bGetCopyToOutputDirectoryItems%3bSatelliteDllsProjectOutputGroup%3b</IncludeOutputGroupsInVSIX>
<IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup%3b</IncludeOutputGroupsInVSIXLocalOnly>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Commands\BuildAurelia\" />
<Folder Include="Snippets\JavaScript\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
6 changes: 3 additions & 3 deletions Aurelia.DotNet.VSIX/Aurelia.DotNet.VSIXPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ protected override async System.Threading.Tasks.Task InitializeAsync(Cancellatio
await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
Logger.Initialize(this, VsixInfo.Name);

await Aurelia.DotNet.VSIX.Commands.UpdateAurelia.UpdateAureliaCommand.InitializeAsync(this);
await Aurelia.DotNet.VSIX.Commands.CreateAurelia.Command1.InitializeAsync(this);
await Aurelia.DotNet.VSIX.Commands.GenerateElement.GenerateElement.InitializeAsync(this);
await Aurelia.DotNet.VSIX.Commands.GenerateElement.InitializeAsync(this);
await Aurelia.DotNet.VSIX.Commands.GenerateRoute.InitializeAsync(this);
await Aurelia.DotNet.VSIX.Commands.GenerateAttribute.InitializeAsync(this);
}

protected override void Dispose(bool disposing)
Expand Down
3 changes: 3 additions & 0 deletions Aurelia.DotNet.VSIX/Commands/AureliaCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ internal sealed partial class PackageIds
public const int CommandGroup = 0x2000;

public const int cmdGenerateElement = 0x0100;
public const int cmdGenerateAttribute = 0x0110;
public const int cmdGenerateRoute = 0x0120;

public const int cmdUpdateAurelia = 0x0150;
}
}
32 changes: 29 additions & 3 deletions Aurelia.DotNet.VSIX/Commands/AureliaCommands.vsct
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,41 @@
<Buttons>
<Button guid="guidAureliaCommandsSet" id="cmdGenerateElement" priority="0x0100" type="Button">
<Parent guid="guidAureliaCommandsSet" id="CommandGroup" />
<Icon guid="ImageCatalogGuid" id="Copy" />
<Icon guid="ImageCatalogGuid" id="NewItem" />
<CommandFlag>IconIsMoniker</CommandFlag>
<CommandFlag>TextChanges</CommandFlag>
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>

<Strings>
<ButtonText>Generate Element</ButtonText>
<ButtonText>Add Element</ButtonText>
<LocCanonicalName>.Aurelia.GenerateElement</LocCanonicalName>
</Strings>
</Button>
<Button guid="guidAureliaCommandsSet" id="cmdGenerateAttribute" priority="0x0110" type="Button">
<Parent guid="guidAureliaCommandsSet" id="CommandGroup" />
<Icon guid="ImageCatalogGuid" id="NewAttribute" />
<CommandFlag>IconIsMoniker</CommandFlag>
<CommandFlag>TextChanges</CommandFlag>
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<Strings>
<ButtonText>Add Attribute</ButtonText>
<LocCanonicalName>.Aurelia.GenerateAttribute</LocCanonicalName>
</Strings>
</Button>
<Button guid="guidAureliaCommandsSet" id="cmdGenerateRoute" priority="0x0120" type="Button">
<Parent guid="guidAureliaCommandsSet" id="CommandGroup" />
<Icon guid="ImageCatalogGuid" id="RouteService" />
<CommandFlag>IconIsMoniker</CommandFlag>
<CommandFlag>TextChanges</CommandFlag>
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>

<Strings>
<ButtonText>Add Route</ButtonText>
<LocCanonicalName>.Aurelia.GenerateRoute</LocCanonicalName>
</Strings>
</Button>
</Buttons>


Expand Down Expand Up @@ -77,6 +101,8 @@
<IDSymbol name="CommandGroup" value="0x2000" />

<IDSymbol name="cmdGenerateElement" value="0x0100" />
<IDSymbol name="cmdGenerateAttribute" value="0x0110" />
<IDSymbol name="cmdGenerateRoute" value="0x0120" />
</GuidSymbol>
</Symbols>
</CommandTable>
105 changes: 0 additions & 105 deletions Aurelia.DotNet.VSIX/Commands/CreateAurelia/Command1.cs

This file was deleted.

Binary file not shown.
Loading

0 comments on commit 30ba6fa

Please sign in to comment.