Skip to content

Commit b5d23e2

Browse files
committed
Refactor templates and enhance security structure
- Removed `.mapper.cs.txt` template and replaced `PermissionSet` with `Security` in `CleanArchitectureCodeGenerator.csproj`. - Updated command and query generation in `CodeGeneratorPackage.cs` to focus on security. - Modified `GetTemplateFilePathAsync` to reflect template structure changes. - Removed the `.mapper.cs.txt` template, indicating a refactor of mapping functionality. - Changed method signature in `.razor.txt` for `ShowEditFormDialog`. - Introduced a new `Permissions` class in `.cs.txt` for a structured approach to permission handling.
1 parent d03b46f commit b5d23e2

6 files changed

Lines changed: 7 additions & 52 deletions

File tree

src/CleanArchitectureCodeGenerator.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@
111111
<DependentUpon>source.extension.vsixmanifest</DependentUpon>
112112
</Compile>
113113
<Compile Include="TemplateMap.cs" />
114-
<Content Include="Templates\Mappers\.mapper.cs.txt">
115-
<IncludeInVSIX>true</IncludeInVSIX>
116-
</Content>
117114
<Content Include="Templates\Pages\.create.razor.txt">
118115
<IncludeInVSIX>true</IncludeInVSIX>
119116
</Content>
@@ -123,7 +120,7 @@
123120
<Content Include="Templates\Pages\.edit.razor.txt">
124121
<IncludeInVSIX>true</IncludeInVSIX>
125122
</Content>
126-
<Content Include="Templates\PermissionSet\.cs.txt">
123+
<Content Include="Templates\Security\.cs.txt">
127124
<IncludeInVSIX>true</IncludeInVSIX>
128125
</Content>
129126
<Content Include="Templates\Specifications\ByIdSpecification.cs.txt">

src/CodeGeneratorPackage.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ private void ExecuteAsync(object sender, EventArgs e)
125125
$"{nameofPlural}/Commands/Import/Import{nameofPlural}CommandValidator.cs",
126126
$"{nameofPlural}/Caching/{name}CacheKey.cs",
127127
$"{nameofPlural}/DTOs/{name}Dto.cs",
128-
/*$"{nameofPlural}/Mappers/{name}Mapper.cs",*/
129128
$"{nameofPlural}/EventHandlers/{name}CreatedEventHandler.cs",
130129
$"{nameofPlural}/EventHandlers/{name}UpdatedEventHandler.cs",
131130
$"{nameofPlural}/EventHandlers/{name}DeletedEventHandler.cs",
@@ -136,7 +135,8 @@ private void ExecuteAsync(object sender, EventArgs e)
136135
$"{nameofPlural}/Queries/GetAll/GetAll{nameofPlural}Query.cs",
137136
$"{nameofPlural}/Queries/GetById/Get{name}ByIdQuery.cs",
138137
$"{nameofPlural}/Queries/Pagination/{nameofPlural}PaginationQuery.cs",
139-
138+
$"{nameofPlural}/Security/{nameofPlural}Permissions.cs",
139+
140140
};
141141
foreach (var item in list)
142142
{
@@ -150,7 +150,7 @@ private void ExecuteAsync(object sender, EventArgs e)
150150
$"Pages/{nameofPlural}/View{name}.razor",
151151
$"Pages/{nameofPlural}/{nameofPlural}.razor",
152152
$"Pages/{nameofPlural}/Components/{name}FormDialog.razor",
153-
$"Pages/{nameofPlural}/Components/{nameofPlural}AdvancedSearchComponent.razor"
153+
//$"Pages/{nameofPlural}/Components/{nameofPlural}AdvancedSearchComponent.razor"
154154
};
155155
foreach (var item in pages)
156156
{

src/Templatemap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static async Task<string> GetTemplateFilePathAsync(Project project, Intel
5858
"Pages",
5959
"Pages\\Components",
6060
"Persistence\\Configurations",
61-
"PermissionSet",
61+
"Security",
6262
};
6363
var extension = Path.GetExtension(file).ToLowerInvariant();
6464
var name = Path.GetFileName(file);

src/Templates/Mappers/.mapper.cs.txt

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/Templates/Pages/.razor.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
_{nameofplurallowercase}Query.Keyword = string.Empty;
211211
await _{nameofplurallowercase}Grid.ReloadServerData();
212212
}
213-
private async Task ShowEditFormDialog(string title, AddEdit{itemname}Command command)
213+
private Task ShowEditFormDialog(string title, AddEdit{itemname}Command command)
214214
{
215215
return DialogServiceHelper.ShowFormDialogAsync<{itemname}FormDialog, AddEdit{itemname}Command>(
216216
title,
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
//------------------------------------------------------------------------------
99

1010

11-
using System.ComponentModel;
1211

13-
namespace {namespace};
12+
namespace CleanArchitecture.Blazor.Application.Common.Security;
1413

1514
public static partial class Permissions
1615
{

0 commit comments

Comments
 (0)