Skip to content

Commit

Permalink
Add support for emitting dynamic properties on open types for "OData …
Browse files Browse the repository at this point in the history
…V4".
  • Loading branch information
unchase committed Sep 21, 2019
1 parent 74058cc commit a81cffa
Show file tree
Hide file tree
Showing 13 changed files with 305 additions and 14 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@

These are the changes to each version that has been released on the official [Visual Studio extension gallery](https://marketplace.visualstudio.com/items?itemName=unchase.UnchaseODataConnectedService).

## v1.3.1 `2019-09-21`

- [x] Add support for emitting dynamic properties on open types for `OData V4`

## v 1.3.0 `2019-09-21`

- [x] Close the [issue #5](https://github.com/unchase/Unchase.Odata.Connectedservice/issues/5):
- [x] Add support for loading client code generation parameters from json files (including `Connected Service .json` from OData Connected Service by Microsoft)
- [x] Add support for loading client code generation parameters from json files (including `Connected Service .json` from `OData Connected Service` by Microsoft)
- [x] Fix bug with multiple untrusted sertificate validation (if multiple OData services are hosted on one endpoint)
- [x] Add more code generation parameters to stored `UserSettings`
- [x] Add `Excluded Operation imports names` to OData V4 generation template for excluding `OperationImports` you need
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ Install from `Tools -> Extensions and Updates` menu inside [Visual Studio](https
## Features

- Generate `C#` and `VB` clients/proxies (client code) from OData specifications for OData protocol versions 1.0-4.0
- Support for emitting dynamic properties on open types for OData protocol version 4.0
- Support selection `OperationImports` (`Actions` and `FunctionImports`) that will be generated for OData protocol versions 1.0-4.0
- Support loading client code generation parameters from json files (including `Connected Service .json` from OData Connected Service by Microsoft)
- Generate `C#` proxy-class extension methods for OData protocol versions 1.0-3.0
- Generate functions to call service methods from OData protocol versions 1.0-3.0 `FunctionImports` or from OData protocol version 4.0 `OperationImports`
- You can select the necessary methods that will be added after generation for OData protocol versions 1.0-4.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ private async Task AddT4FileAsync()

text = Regex.Replace(text, "(public const bool EnableNamingAlias = )true;", "$1" + this.ServiceConfiguration.EnableNamingAlias.ToString().ToLower(CultureInfo.InvariantCulture) + ";");
text = Regex.Replace(text, "(public const bool IgnoreUnexpectedElementsAndAttributes = )true;", "$1" + this.ServiceConfiguration.IgnoreUnexpectedElementsAndAttributes.ToString().ToLower(CultureInfo.InvariantCulture) + ";");
text = Regex.Replace(text, "(public const bool GenerateDynamicPropertiesCollection = )true;", "$1" + this.ServiceConfiguration.GenerateDynamicPropertiesCollection.ToString().ToLower(CultureInfo.InvariantCulture) + ";");
text = Regex.Replace(text, "(public const string DynamicPropertiesCollectionName = )\"DynamicProperties\";", "$1\"" + $"{(!string.IsNullOrWhiteSpace(ServiceConfiguration.DynamicPropertiesCollectionName) ? ServiceConfiguration.DynamicPropertiesCollectionName : Common.Constants.DefaultDynamicPropertiesCollectionName)}" + "\";");

text = Regex.Replace(text, "(public const string ExcludedOperationImportsNames = )\"\";", "$1\"" + this.ServiceConfiguration.ExcludedOperationImportsNames + "\";");

await writer.WriteAsync(text);
Expand Down Expand Up @@ -142,7 +145,9 @@ private async Task AddGeneratedCodeAsync()
IgnoreUnexpectedElementsAndAttributes = this.ServiceConfiguration.IgnoreUnexpectedElementsAndAttributes,
EnableNamingAlias = this.ServiceConfiguration.EnableNamingAlias,
NamespacePrefix = this.ServiceConfiguration.NamespacePrefix,
ExcludedOperationImportsNames = this.ServiceConfiguration?.ExcludedOperationImportsNames
ExcludedOperationImportsNames = this.ServiceConfiguration?.ExcludedOperationImportsNames,
GenerateDynamicPropertiesCollection = this.ServiceConfiguration.GenerateDynamicPropertiesCollection,
DynamicPropertiesCollectionName = this.ServiceConfiguration?.DynamicPropertiesCollectionName
};

var tempFile = Path.GetTempFileName();
Expand Down
1 change: 1 addition & 0 deletions src/Unchase.OData.ConnectedService/Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ internal static class Constants
public const string DefaultReferenceFileName = "Reference";
public const string DefaultNamespacePrefix = "Reference";
public const string DefaultServiceName = "OData Service";
public const string DefaultDynamicPropertiesCollectionName = "DynamicProperties";

public static Version EdmxVersion1 = new Version(1, 0, 0, 0);
public static Version EdmxVersion2 = new Version(2, 0, 0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ internal class ServiceConfigurationV4 : ServiceConfigurationV3

public bool IgnoreUnexpectedElementsAndAttributes { get; set; }

public bool GenerateDynamicPropertiesCollection { get; set; }

public string DynamicPropertiesCollectionName { get; set; }

public bool IncludeT4File { get; set; }
}
#endregion
Expand Down
6 changes: 6 additions & 0 deletions src/Unchase.OData.ConnectedService/Models/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ internal class UserSettings
[DataMember]
public bool IgnoreUnexpectedElementsAndAttributes { get; set; }

[DataMember]
public bool GenerateDynamicPropertiesCollection { get; set; } = true;

[DataMember]
public string DynamicPropertiesCollectionName { get; set; } = Constants.DefaultDynamicPropertiesCollectionName;

[DataMember]
public bool IncludeT4File { get; set; }

Expand Down
Loading

0 comments on commit a81cffa

Please sign in to comment.