The current input path handling is problematic and error prone.
Steps to reproduce a problem:
- Create a sample project
mkdir SampleXX
cd SampleXX
dotnet new mvc
mkdir Localization
- Try to invoke the program with the path of the project and localization path:
- `dotnet run -- path/to/SampleXX/ path/to/SampleXX/Localization
Expected outcome
Found 0 strings
Actual outcome
Unhandled exception. System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string. (Parameter 'startIndex')
at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length)
at System.String.Substring(Int32 startIndex, Int32 length)
at OrchardCoreContrib.PoExtractor.Program.<>c__DisplayClass0_0.<<Main>b__3>d.MoveNext()
Analysis
The input path logic with project base and rooted projects is fragile and should be rethought in the context of how this tool is to be used. I guess it works for Orchard CMS as it is used today, but is fragile if used on other projects.
The simple workaround is to not include the trailing directory separator (/) in the first argument.
I also believe it not a best practice that ignored projects is populated with the predefined strings and that the ignored projects should be rather renamed to ignored paths that will not be searched for the C# projects and/or template files.
The current input path handling is problematic and error prone.
Steps to reproduce a problem:
mkdir SampleXXcd SampleXXdotnet new mvcmkdir LocalizationExpected outcome
Found 0 strings
Actual outcome
Analysis
The input path logic with project base and rooted projects is fragile and should be rethought in the context of how this tool is to be used. I guess it works for Orchard CMS as it is used today, but is fragile if used on other projects.
The simple workaround is to not include the trailing directory separator (
/) in the first argument.I also believe it not a best practice that ignored projects is populated with the predefined strings and that the ignored projects should be rather renamed to ignored paths that will not be searched for the C# projects and/or template files.