Skip to content

A Visual Studio extension for generating client code for OData Services

License

Notifications You must be signed in to change notification settings

OData/ODataConnectedService

Repository files navigation

OData CodeGenerator Tools

Component Build Status
Connected Service Rolling Build Status

Introduction

This is the official OData CodeGenerator tools repository. The OData CodeGenerator tools allow users to generate proxy classes from OData Metadata. These proxy classes are used by OData client to interact with an OData service. These tools work for both VB.NET and C# projects.

The OData Code Generator tools in this repository are:

  1. OData Connected Service
  2. OData CLI.

These tools lets app developers connect their applications to OData Services (both V3 & V4) and generate the client proxy files for the services.

OData Connected Service supports Visual Studio 2017, Visual Studio 2019 and Visual Studio 2022.

This project is ready to be used in production environment and is currently actively being supported.

To learn more about OData please visit the OData website. To learn more about Microsoft OData Libraries see documention here.

Why OData Code Generator Tools?

Do you have an OData service you would like to integrate in your Microsoft .NET application? The OData Code Generator tools make your life easier since you can use them to automatically generate proxy classes which are much easier to call. The ability of these tools to rapidly generate and update these classes makes your development faster. Please check on the documentation on:

  1. How to install and use Connected service to generate these classes.

  2. How to install and use OData CLI to generate these classes.

Getting started

To get started with these OData Code Generator tools, please check on the documentation links shared above.

OData Connected Service Extension

The OData Connected Service documentation and other artifacts can be found in the two following places:

OData CLI

The OData CLI documentation and other artifacts can be found in the two following places:

Building

In order to build the application Visual Studio 2019/2017/2022 is the recommended development environment with the VSIX development tools installed.

The repository has 6 projects in one solution. The projects are:

  1. Microsoft.OData.Cli
  2. Microsoft.OData.CodeGen
  3. ODataConnectedService
  4. ODataConnectedService.Shared
  5. ODataConnectdService.Tests
  6. ODataConnectedService.VS2022Plus

Building in visual studio

Open the ODataCodeGenTools.sln in visual studio and install any suggested extensions that may be missing in your instance. Build and run the project.

While developing if you encounter any issues do check the FAQ section below for frequently asked questions

Unit Tests

The ODataConnectedService.Tests project contains the unit tests for the OData connected service. The folder structure of the tests mirrors the folder structure of the ODataConnectedService.Shared project. The base namespace for tests is Microsoft.OData.ConnectedService.Tests. Furthermore each test class has the same name as the class it is testing, followed by the suffix Test.

Example: for some class Microsoft.OData.ConnectedService.X.Y located in src\X\Y.cs, the test class would be Microsoft.OData.Tests.ConnectedService.Tests.X.YTest located in test\X\YTest.cs

Building Command-line

The project can also be build using on the command-line by relying on the provided build.cmd

Other related Projects

FAQ

Question: The extension module is not loaded when debugging in the Visual Studio experimental instance, or it is not listed as part of the "Add Connected Service" options Workaround: Disable strong name verification for the main and test assemblies. You can do that using the sn.exe tool from the Visual Studio Developer Command Prompt. First, build the solution using Visual Studio, then open the developer command prompt with Adminstrator privileges and run the following commands:

For the main assembly:

sn.exe -Vr path\to\ODataConnectedService\src\bin\Debug\Microsoft.OData.ConnectedService.dll

For the test assembly:

sn.exe -Vr path\to\ODataConnectedService\test\ODataConnectedService.Tests\bin\Debug\ODataConnectedServiceTests.dll

Then restart Visual Studio.

If disabling verification is not an option, then you can disable signing by going to the Project Properties > Signing and disabling both "Sign the assembly" and "Delay sign only" options. Do this for both the main and test projects. Then open the AssemblyInfo.cs file under the main project's properties in solution explorer and remove the public key from the [assembly: InternalsVisibleTo("ODataConnectedService.Tests, PublicKey=...")] attribute so that it only reads as [assembly: InternalsVisibleTo("ODataConnectedService.Tests")]. Remember to re-enable delay-signing and to restore the public key before commiting your changes.

Question: In Visual Studio 2017, upon configuring the service endpoint in the OData Connected Services extension and clicking "Finish", I get an error message that says "Cannot access".
Workaround: Most reported issues for this error are related to authentication-based endpoints. This extension does not currently support authentication. To work around, download the metadata as a text file from the endpoint and then point the OData Connected Services URI to the downloaded file.

High Level roadmap for OData Connected Service

OData Connected Service is considered a stable product. Below are some planned improvements:

  • Make code Generator cross-platform. This is to take care of developers using Visual Studio code in non-Windows environments.
  • Make it more seamless to generate code from the command line and consequently in build pipelines to enhance automations.

Contribution

There are many ways for you to contribute to OData Connected services. The easiest way is to participate in discussion of features and issues. You can also contribute by sending pull requests of features or bug fixes to us. Contribution to the documentations is also highly welcomed. Please refer to the CONTRIBUTING.md for more details.

Reporting Security Issues

Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) [email protected]. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter. You can also find these instructions in this repo's SECURITY.md.

Support

Code of Conduct

This project has adopted the .NET Foundation Contributor Covenant Code of Conduct. For more information see the Code of Conduct FAQ.

.NET Foundation

This project is supported by the .NET Foundation.

OData Connected Service is a Copyright © .NET Foundation and other contributors. It is licensed under MIT License