Skip to content

Problematic input path handling #108

@skyflyer

Description

@skyflyer

The current input path handling is problematic and error prone.

Steps to reproduce a problem:

  1. Create a sample project
  • mkdir SampleXX
  • cd SampleXX
  • dotnet new mvc
  • mkdir Localization
  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions