Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 adapt to new solution structure #68

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/CleanArchitectureCodeGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
<Content Include="Templates\Pages\.razor.txt">
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="Templates\Pages\.formdialog.razor.txt">
<Content Include="Templates\Pages\Components\.formdialog.razor.txt">
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="Templates\Pages\Components\.advancedsearchcomponent.razor.txt">
Expand Down
17 changes: 11 additions & 6 deletions src/CodeGeneratorPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ namespace CleanArchitecture.CodeGenerator
[Guid(PackageGuids.guidCodeGeneratorPkgString)]
public sealed class CodeGeneratorPackage : AsyncPackage
{
public const string DOMAINPROJECT = "Domain";
public const string UIPROJECT = "Server.UI";
public const string INFRASTRUCTUREPROJECT = "Infrastructure";
public const string APPLICATIONPROJECT = "Application";

private const string _solutionItemsProjectName = "Solution Items";
private static readonly Regex _reservedFileNamePattern = new Regex($@"(?i)^(PRN|AUX|NUL|CON|COM\d|LPT\d)(\.|$)");
private static readonly HashSet<char> _invalidFileNameChars = new HashSet<char>(Path.GetInvalidFileNameChars());
Expand All @@ -53,17 +58,17 @@ protected async override System.Threading.Tasks.Task InitializeAsync(Cancellatio
private void ExecuteAsync(object sender, EventArgs e)
{
NewItemTarget target = NewItemTarget.Create(_dte);
NewItemTarget domain= NewItemTarget.Create(_dte,"Domain");
NewItemTarget infrastructure = NewItemTarget.Create(_dte, "Infrastructure");
NewItemTarget ui = NewItemTarget.Create(_dte, "Blazor.Server.UI");
NewItemTarget domain= NewItemTarget.Create(_dte, DOMAINPROJECT);
NewItemTarget infrastructure = NewItemTarget.Create(_dte, INFRASTRUCTUREPROJECT);
NewItemTarget ui = NewItemTarget.Create(_dte, UIPROJECT);
var includes = new string[] { "IEntity", "BaseEntity", "BaseAuditableEntity", "BaseAuditableSoftDeleteEntity", "AuditTrail", "OwnerPropertyEntity" };
var objectlist = ProjectHelpers.GetEntities(domain.Project)
.Where(x => includes.Contains(x.BaseName) && !includes.Contains(x.Name));
var entities = objectlist.Select(x=>x.Name).Distinct().ToArray();
if (target == null)
if (target == null && target.Project.Name == APPLICATIONPROJECT)
{
MessageBox.Show(
"Could not determine where to create the new file. Select a file or folder in Solution Explorer and try again.",
"Unable to determine the location for creating the new file. Please select a folder within the Application Project in the Explorer and try again.",
Vsix.Name,
MessageBoxButton.OK,
MessageBoxImage.Error);
Expand Down Expand Up @@ -137,7 +142,7 @@ private void ExecuteAsync(object sender, EventArgs e)
var pages = new List<string>()
{
$"Pages/{nameofPlural}/{nameofPlural}.razor",
$"Pages/{nameofPlural}/_{name}FormDialog.razor",
$"Pages/{nameofPlural}/Components/{name}FormDialog.razor",
$"Pages/{nameofPlural}/Components/{nameofPlural}AdvancedSearchComponent.razor"
};
foreach (var item in pages)
Expand Down
4 changes: 2 additions & 2 deletions src/Templatemap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ private static string createMudTdHeaderDefinition(IntellisenseObject classObject
}
if (classObject.Properties.Where(x => x.Type.IsKnownType == true && x.Name == defaultfieldName.Last()).Any())
{
output.Append($" <MudText Typo=\"Typo.body2\" Style=\"@($\"color:{{Theme.Theme.ApplicationTheme().Palette.TextSecondary}}\")\">@context.Item.Description</MudText>\r\n");
output.Append($" <MudText Typo=\"Typo.body2\" Class=\"mud-text-secondary\">@context.Item.Description</MudText>\r\n");
}
output.Append($" </div>\r\n");
output.Append(" </CellTemplate>\r\n");
Expand Down Expand Up @@ -335,7 +335,7 @@ private static string createMudTdDefinition(IntellisenseObject classObject)
}
if (classObject.Properties.Where(x => x.Type.IsKnownType == true && x.Name == defaultfieldName.Last()).Any()) {
output.Append(" ");
output.Append($" <MudText Typo=\"Typo.body2\" Style=\"@($\"color:{{Theme.Theme.ApplicationTheme().Palette.TextSecondary}}\")\">@context.Description</MudText>\r\n");
output.Append($" <MudText Typo=\"Typo.body2\" Class=\"mud-text-secondary\">@context.Description</MudText>\r\n");
}
output.Append(" ");
output.Append($" </div>\r\n");
Expand Down
14 changes: 7 additions & 7 deletions src/Templates/Pages/.razor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@using CleanArchitecture.Blazor.Application.Features.{nameofPlural}.Queries.Export
@using CleanArchitecture.Blazor.Application.Features.{nameofPlural}.Queries.Pagination
@using CleanArchitecture.Blazor.Application.Features.{nameofPlural}.Commands.AddEdit

@using CleanArchitecture.Blazor.Server.UI.Pages.{nameofPlural}.Components
@inherits FluxorComponent
@inject IJSRuntime JS
@inject IStringLocalizer<{nameofPlural}> L
Expand Down Expand Up @@ -280,12 +280,12 @@
private async Task OnCreate()
{
var command = new AddEdit{itemname}Command();
var parameters = new DialogParameters<_{itemname}FormDialog>
var parameters = new DialogParameters<{itemname}FormDialog>
{
{ x=>x.model,command },
};
var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.Medium, FullWidth = true };
var dialog = DialogService.Show<_{itemname}FormDialog>
var dialog = DialogService.Show<{itemname}FormDialog>
(L["Create a new item"], parameters, options);
var state = await dialog.Result;
if (!state.Canceled)
Expand All @@ -300,12 +300,12 @@
Name = copyitem.Name,
Description = copyitem.Description,
};
var parameters = new DialogParameters<_{itemname}FormDialog>
var parameters = new DialogParameters<{itemname}FormDialog>
{
{ x=>x.model,command },
};
var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.Medium, FullWidth = true };
var dialog = DialogService.Show<_{itemname}FormDialog>
var dialog = DialogService.Show<{itemname}FormDialog>
(L["Create a new item"], parameters, options);
var state = await dialog.Result;
if (!state.Canceled)
Expand All @@ -317,12 +317,12 @@
private async Task OnEdit({itemname}Dto dto)
{
var command = Mapper.Map<AddEdit{itemname}Command>(dto);
var parameters = new DialogParameters<_{itemname}FormDialog>
var parameters = new DialogParameters<{itemname}FormDialog>
{
{ x=>x.model,command },
};
var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.Medium, FullWidth = true };
var dialog = DialogService.Show<_{itemname}FormDialog>
var dialog = DialogService.Show<{itemname}FormDialog>
(L["Edit the item"], parameters, options);
var state = await dialog.Result;
if (!state.Canceled)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text.Json;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace {namespace};
Expand Down
Loading