OData Connected Service version 0.5.0 Release

Avatar

OData Connected Service 0.5.0 has been released and is available in the Visual Studio Marketplace.

The new version has the following new features:

  1. A new version of the Microsoft.OData.Client library(v7.6.3)
  2. Supports mocking of the generated functions and properties.
  3. An option to open the generated files in the IDE after code generation.

In addition to the above features, the new version has the following improvements and fixes:

  1. Generation of type definitions using their underlying types.
  2. The Microsoft WCF Toolkit dependency has been removed.
  3. All features and fixes from OData Client Code Generator are now in OData Connected Service.

Microsoft.OData.Client v7.6.3

OData Connected Service version 0.5.0 comes with Microsoft.OData.Client v7.6.3 which has great improvements: Some of the improvements are: 

  1. Save ODataPath ToList for improved performance.
  2. Performance improvements in FunctionOverloadResolver.
  3. Fixes for OData.net Client throwing InvalidOperationException when calling ‘Move’ on a DataServiceCollection.
  4. Fixes for supporting escape function and key values terminating in colon.
  5. Fixes for IN operator fails on strings with commas in them.
  6. Allow Microsoft.OData.Client.Serializer.GetKeyString to receive an IDictionary Object.
  7. Fixes for $filter in (null) not working.
  8. Fixes for Combine Dispose methods on JsonWriter.

Supports Mocking of the generated functions and properties

The generated methods and properties can be mocked for purposes of testing your client code. You can use any Mock Framework to mock these methods.The following is a simple example to show that the generated methods can be mocked using the Moq Framework.

public string AddPerson(DefaultContainer defaultContainer)
{
    Person person = new Person
    {
        FirstName = "PersonA"
        //…there are many more fields here. 
    };
    try
    {
        defaultContainer.AddToPeople(person).
        return "Saved Successfully".
    } catch (Exception exception)
    {
        return "Not Saved Successfully”. 
    }   
}

Using the Moq Framework, we can setup the AddToPeople() method to return whatever we want it to return whenever we call it. Like below.

public void Return_SavedSuccessfully_WhenAddToPeopleMethodIsCalled()
{
     string response = "Add".
     Mock<DefaultContainer> mock = new Mock<DefaultContainer>(null).
     mock.CallBase = true;
     mock.Setup(x => x.AddToPeople(It.IsAny<Person>())).Callback(() => { response = "Saved Successfully"; });
     Users users = new Users ();
     string result = users.AddPerson(mock.Object);
     Assert.Equal(result, response).
}

An Option to open the generated files in the IDE after code generation

This option has been added on the OData Connected Service setup wizard. It is on the Advanced Settings page. You can use this setting when you want the generated file to open in the IDE after code generation.To set this option, follow the following steps:

If you have the OData Connected Service extension installed,

  1. Right click on the project you are working on from the solution explorer.
  2. Select Add->Connected Service from the context menu.
  3. From the Connected Service Window that opens, select the Microsoft OData Connected Service.
  4. On the wizard window, configure your service endpoint by providing the service name and the OData URL endpoint then click Next.
  5. On the Next page, click on the “AdvancedSettings” link.

Image snap1

Check the checkbox beside the “Open generated files in the IDE when generation completes” configuration on this page then click finish.

Image snap2

The generated file will open in the IDE once the code generation process completes.

Generation of type definitions using their underlying types.

The previous versions of OData Connected Service could not generate code for an endpoint whose schema had:

  1. Elements with type definitions like the Outlook Beta API  
    <TypeDefinition Name="DateTime" UnderlyingType="Edm.String"/>
  2. Functions with parameters whose types are based on type definitions like below:
    <Function Name="MyFunc" IsBound="true">
       <Parameter Name="StartDate" Type="MyNamespace.DateTime" />
       <ReturnType Type="Edm.Int32" Nullable="false" />
    </Function>
    

This issue has been solved in the OData Connected Service version 0.5.0. The OData Connected Service can now generate type definitions using their underlying types without any errors or exceptions.

All features and fixes from OData Client Code Generator are now in OData Connected Service.

The OData Connected Service version 0.5.0 is now in sync with the latest version of the Microsoft OData Client Code Generator. All features and fixes in the Microsoft OData Client Code Generator are now available in OData Connected Service.

Removed the Microsoft WCF Toolkit dependency .

The Microsoft WCF Toolkit dependency has been removed from this version. That is, you do not need to install the WCF Toolkit for you to generate client code.

There are more features and fixes coming to OData Connected Service soon, so stay tuned for upcoming releases.

0 comments

Comments are closed.