OData / ODataConnectedService

A Visual Studio extension for generating client code for OData Services
Other
81 stars 44 forks source link

Adding OData-Service to legacy .NET Framework project fails with: "Value does not fall within the expected range." #340

Open GandalfClashs opened 1 year ago

GandalfClashs commented 1 year ago

Related to #137

Describe the bug

When I try to add an OData-Service to a legacy .NET Framework project, which already has a Service Reference to a WCF Service, i get the error message "Value does not fall within the expected range." after "Generating Client Proxy for OData V4...".

Version of the Project affected

ODataConnectedService 2022+ v1.0.0 and earlier VisualStudio Version v17.4.5 Microsoft.Odata.Client v7.14.1

To Reproduce

Steps to reproduce the behavior:

  1. Create a new .NET Framework console project
  2. Add a folder named "Service References" to the project
  3. Replace "Folder" with "WCFMetadata" for the created folder in the project file:
    <ItemGroup>
    <WCFMetadata Include="Service References\" />
    </ItemGroup>
  4. Reload the project
  5. Add an OData-Service with the ODataConnectedService wizard (e.g. https://services.odata.org/V4/Northwind/Northwind.svc/$metadata) and leave all settings in the wizard on default

Expected behavior

The OData-Service is added successfully.

Actual behavior

The addition of the service to the project fails.

Additional context

The folder name "Connected Services" is hard-coded in the ConnectedServiceFileHandler. In legacy projects the services root folder doesn't always have this name.