Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI generate command fails silently when you pass a V1 schema #397

Open
habbes opened this issue May 23, 2024 · 0 comments
Open

CLI generate command fails silently when you pass a V1 schema #397

habbes opened this issue May 23, 2024 · 0 comments

Comments

@habbes
Copy link
Contributor

habbes commented May 23, 2024

Describe the bug

The generate command completes without generating code when you pass a V1 (or V2) schema.

Version of the Project affected

OData CLI 0.3.0

To Reproduce

  1. Get an OData V1 schema file
  2. Run odata-cli generate -m my-v1-schema.xml -o output-dir

The command completes without emitting any errors, but no file is generated in the output directory.

Expected behavior

The output directory should contain generated code.

If there are any errors, they should be logged.

Actual behavior

No code is generated. No error is emitted.

Additional context

The offending code comes from the following snippet in GenerateCommand.cs: https://github.com/OData/ODataConnectedService/blob/master/src/Microsoft.OData.Cli/GenerateCommand.cs#L228

if (version == Constants.EdmxVersion4)
{
      await GenerateCodeForV4Clients(options, console).ConfigureAwait(false);
}
 else if (version == Constants.EdmxVersion3)
{
       await GenerateCodeForV3Clients(options, console).ConfigureAwait(false);
}

We check whether the version is V4 or V3 only. The GenerateCodeForV3Clients method actually supports V1, V2 and V3. So we should check for those as well.

And we should have an else block to emit an error for unsupported versions.

if (version == Constants.EdmxVersion4)
{
      await GenerateCodeForV4Clients(options, console).ConfigureAwait(false);
}
 else if (version == Constants.EdmxVersion3 || version == Constants.EdmxVersion2 || version == Constants.EdmxVersion1)
{
       await GenerateCodeForV3Clients(options, consol, version).ConfigureAwait(false);
}
else
{
       ReportUnsupportedVersionError();
}
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

No branches or pull requests

1 participant