GIS Converter - Console App -Final code

Dani_S 4,966 Reputation points
2025-12-17T08:06:32.76+00:00

Hi Michel,

Thank you very much for your help !!!

I implemented all your remarks from ticket:

https://learn.microsoft.com/en-us/answers/questions/5658212/gis-cli-commands

Can you please look on all code and see if it ok ?

Files

Program code:

GitConverter ConsoleApp README.txt

Program.txt

Thanks in advance,

Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Michael Le (WICLOUD CORPORATION) 7,020 Reputation points Microsoft External Staff Moderator
    2025-12-18T02:24:10.8833333+00:00

    Hello @Dani_S ,

    I see you've put in solid effort implementing the feedback. There are a few things that need adjustment before this is ready though.

    The main method issue

    Your Main method currently looks like this:

    private static void Main(string[] args)
    {
        // ... license check ...
        Environment.Exit(Run(args));
    }
    
    

    This conflicts with what your own readme says about testing. Calling Environment.Exit here will kill the test runner. Change it to:

    private static int Main(string[] args)
    {
        if (! AsposeLicenseManager.ApplyLicense())
        {
            Console.Error.WriteLine("⚠️ Failed to apply Aspose license.");
            return (int)ExitCode.AppError;
        }
    
        Console. OutputEncoding = System.Text. Encoding.UTF8;
        args = EnsureDebugArgs(args);
        return Run(args);
    }
    

    The argument repair logic

    TryRepairUnquotedInputArgs tries to fix paths with spaces that weren't quoted. Most cli tools just require proper quoting and throw clear errors when paths are malformed. Consider validating early instead:

    if (! File.Exists(inputPath) && !Directory.Exists(inputPath))
    {
        Console.WriteLine($"❌ Input path not found: {inputPath}");
        Console.WriteLine("Note: Wrap paths containing spaces in quotes");
        return (int)ExitCode.AppError;
    }
    

    Magic numbers

    You have if (args.Length < 6) and GetOptionalLogArguments(args, 5) scattered throughout. Use named constants so the code documents itself:

    private const int MIN_REQUIRED_ARGS = 5;
    private const int LOG_ARGS_START_INDEX = 5;
    

    The single command switch

    Your Run method has a switch statement with only one case (gis_convert). Since you only support one command, a simple equality check is clearer:

    if (! args[0]. Equals("gis_convert", StringComparison.OrdinalIgnoreCase))
    {
        Console.WriteLine($"❌ Unknown command: {args[0]}\n");
        ShowHelp();
        return (int)ExitCode.AppError;
    }
    
    return RunGisConverter(args);
    
    You found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2025-12-17T08:06:42.0966667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    I'm unable to review the code or provide feedback on specific implementations as the context does not contain information on code review processes or specific programming practices. For assistance with your code, consider reaching out to a community of developers or using platforms dedicated to code reviews.


    References:


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.