unchase / Unchase.Odata.Connectedservice

:scroll: A Visual Studio extension for connecting to OData services with generating client-side C# proxy-classes
Apache License 2.0
44 stars 13 forks source link

Cannot convert from 'System.Xml.XmlReader' to System.Collections.Generic.IEnumerable<System.Xml.XmlReader>' #47

Closed Pantzer-byte closed 4 years ago

Pantzer-byte commented 4 years ago

Describe the bug

When generating model classes, I get two errors in my LoadModelFromString method in the Reference.cs class:

    private static global::Microsoft.OData.Edm.IEdmModel LoadModelFromString()
    {
        global::System.Xml.XmlReader reader = CreateXmlReader(Edmx);
        try
        {
            global::System.Collections.Generic.IEnumerable<global::Microsoft.OData.Edm.Validation.EdmError> errors;
            global::Microsoft.OData.Edm.IEdmModel edmModel;

            if (!global::Microsoft.OData.Edm.Csdl.CsdlReader.TryParse(reader, false, out edmModel, out errors))
            {
                global::System.Text.StringBuilder errorMessages = new global::System.Text.StringBuilder();
                foreach (var error in errors)
                {
                    errorMessages.Append(error.ErrorMessage);
                    errorMessages.Append("; ");
                }
                throw new global::System.InvalidOperationException(errorMessages.ToString());
            }

            return edmModel;
        }
        finally
        {
            ((global::System.IDisposable)(reader)).Dispose();
        }
    }

Argument 1: Cannot convert from 'System.Xml.XmlReader' to System.Collections.Generic.IEnumerable'

Argument 2: cannot convert from 'bool' to 'Microsoft.OData.Edm.IEdmModel'

I need to manually fix the code after each time the Reference class is generated via the Unchase OData Connected Service.

Assemblies affected

Unchase OData Connected Service v1.4.1 Microsoft Visual Studio Professional 2017 15.9.28307.1093

Steps to reproduce

  1. Take my ConnectedService.json file here
  2. Generate Reference class using my metadata file
  3. The error will be present in the LoadModelFromString method of the Reference.cs class
unchase commented 4 years ago

Hi, @Pantzer-byte I tried to reproduce the issue with your data in Visual Studio 2019 v16.6.2 (and Visual Studio 2017 v15.9.23) - there are no errors:

no errors

Try to remove all generated files and generate client code again.

Pantzer-byte commented 4 years ago

Hey @unchase Thank you for your quick reply :) I will try very soon and let you know. Have a nice day!

unchase commented 4 years ago

Hi, @Pantzer-byte Have you tried it?

cbulliraju commented 4 years ago

Hi @unchase,

I have tried, in VS Professional 2015, Version: 14.0.25420.01 Update 3.

Same problem.

Argument 1: Cannot convert from 'System.Xml.XmlReader' to System.Collections.Generic.IEnumerable'

Argument 2: cannot convert from 'bool' to 'Microsoft.OData.Edm.IEdmModel'

unchase commented 4 years ago

VS 2015 does not supports by the Connected Service:

image

You should use VS 2017 or VS 2019 for generating client.

vsundupey commented 3 years ago

Encountered with the same issue, I resolved it by updating OData Nuget packages to newer version.