Skip to content

Conversation

@blackWins
Copy link
Contributor

新增可选参数template-path,用于设置模板加载路径。
注意:指定路径文件需要与项目Templates目录一致。

Add a new optional parameter template-path to set the template loading path.
Note: The specified path file needs to be consistent with the project Templates directory.

This comment was marked as outdated.

@blackWins blackWins requested a review from Copilot June 5, 2025 14:50

This comment was marked as outdated.

@blackWins blackWins requested a review from Copilot July 18, 2025 12:24

This comment was marked as outdated.

@blackWins blackWins requested a review from Copilot July 18, 2025 12:51

This comment was marked as outdated.

@blackWins blackWins requested a review from Copilot July 18, 2025 14:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new optional template-path parameter to enable users to specify custom template loading paths. The implementation allows for fallback to embedded templates when custom templates are not found at the specified path.

Key changes:

  • Added TemplatePath property to CommandOptionsBase with corresponding mapping logic
  • Updated template loading logic across all command classes to use the new path mapping
  • Enhanced file provider extensions to support physical and virtual template directory mirroring

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
AbpHelperCoreConsts.cs Defines template resource path prefix constant
CommandOptionsBase.cs Adds template-path option and path mapping functionality
FileProviderExtensions.cs Implements template directory mirroring and file loading logic
TextGenerator.cs Updates template loading to check physical files first
TemplateLoader.cs Modifies template loading to support physical/virtual file fallback
GroupGenerationStep.cs Uses new template directory mirroring for file generation
Multiple Command files Updates all commands to use the new template path mapping
Comments suppressed due to low confidence (2)

src/AbpHelper.Core/Extensions/FileProviderExtensions.cs:42

  • The variable name 'p' is ambiguous. Consider renaming it to 'file' or 'physicalFile' for better clarity.
            var physicalPaths = new HashSet<string>(physicalFiles.Select(p => p.Item1));

src/AbpHelper.Core/Extensions/FileProviderExtensions.cs:43

  • The variable name 'v' is ambiguous. Consider renaming it to 'file' or 'virtualFile' for better clarity.
            return physicalFiles.Concat(virtualFiles.Where(v => !physicalPaths.Contains(v.Item1)));

return Path.Combine(new[] { resourcePathPrefix, subPath }).NormalizePath();
}

if (AbpHelperCoreConsts.TemplateResourcePathPrefix[0] == '/' || AbpHelperCoreConsts.TemplateResourcePathPrefix[0] == '\\')
Copy link

Copilot AI Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct character indexing can throw IndexOutOfRangeException if the string is empty. Consider using string.StartsWith() method instead for safer string comparison.

Suggested change
if (AbpHelperCoreConsts.TemplateResourcePathPrefix[0] == '/' || AbpHelperCoreConsts.TemplateResourcePathPrefix[0] == '\\')
if (AbpHelperCoreConsts.TemplateResourcePathPrefix.StartsWith("/") || AbpHelperCoreConsts.TemplateResourcePathPrefix.StartsWith("\\"))

Copilot uses AI. Check for mistakes.

public static IEnumerable<(string, IFileInfo)> GetFilesRecursively(this IVirtualFileProvider fileProvider, string dir)
{
var (virtualDirectory, physicalDirectory) = TemplateRootDirectoryMirror(dir);
Copy link

Copilot AI Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The method calls the static TemplateRootDirectoryMirror instead of using the extension method GetTemplateRootDirectoryMirror. This creates inconsistency in the API usage pattern.

Suggested change
var (virtualDirectory, physicalDirectory) = TemplateRootDirectoryMirror(dir);
var (virtualDirectory, physicalDirectory) = fileProvider.GetTemplateRootDirectoryMirror(dir);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant