Skip to content

Commit

Permalink
1) Fixes #7: Add support for loading client code generation parameter…
Browse files Browse the repository at this point in the history
…s from json files (including "Connected Service .json" from OData Connected Service by Microsoft);

2) Fix bug with multiple untrusted sertificate validation (if multiple OData services are hosted on one endpoint);
3) Add more code generation parameters to stored "UserSettings";
4) Add "Excluded Operation imports names" to OData V4 generation template for excluding "OperationImports" you need.
  • Loading branch information
unchase committed Sep 20, 2019
1 parent e350a75 commit 74058cc
Show file tree
Hide file tree
Showing 22 changed files with 425 additions and 204 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +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).

## 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] 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

## v1.2.0 `2019-09-10`

- [x] Code refactoring
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ Install from `Tools -> Extensions and Updates` menu inside [Visual Studio](https

![Unchase OData Connected Service FunctionImports](img/Unchase-OData-Connected-Service-FunctionImports.png)

## Features are supported since v1.3.0

### Loading client code generation parameters from json files (including `Connected Service .json` from OData Connected Service by Microsoft)

![Unchase OData Connected Service Load Parameters](img/Unchase-OData-Connected-Service-LoadJson.png)

## HowTos

- [ ] Add HowTos in a future
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1.2.{build}
version: 1.3.{build}
pull_requests:
do_not_increment_build_number: true
skip_tags: true
Expand Down
Binary file added img/Unchase-OData-Connected-Service-LoadJson.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/Unchase-OData-Connected-Service-ReportBug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/Unchase-OData-Connected-Service-VisualBasic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected string GetReferenceFileFolder()
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
var serviceReferenceFolderName = this.Context.HandlerHelper.GetServiceArtifactsRootFolder();

return Path.Combine(ProjectHelper.GetProjectFullPath(this.Project), serviceReferenceFolderName, this.Context.ServiceInstance.Name);
return Path.Combine(this.Project.GetProjectFullPath(), serviceReferenceFolderName, this.Context.ServiceInstance.Name);
}
#endregion
}
Expand Down
1 change: 0 additions & 1 deletion src/Unchase.OData.ConnectedService/Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,5 @@ public enum OperationImportsGenerator
SimpleOData = 1,
Vipr = 2
}

}
}
10 changes: 10 additions & 0 deletions src/Unchase.OData.ConnectedService/Common/ExtensionsHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2018 Unchase (https://github.com/unchase). All rights reserved.
// Licensed under the Apache License 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
Expand All @@ -17,6 +18,15 @@

namespace Unchase.OData.ConnectedService.Common
{
#region For update from Microsoft OData Connected Service
internal class ConnectedServiceJsonFileData
{
public string ProviderId { get; set; }

public UserSettings ExtendedData { get; set; }
}
#endregion

internal static class ExtensionsHelper
{
#region For Views
Expand Down
6 changes: 3 additions & 3 deletions src/Unchase.OData.ConnectedService/Common/ProjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static Project GetProject(this IVsHierarchy projectHierarchy)
return (Project)projectObject;
}

public static Project GetProjectFromHierarchy(IVsHierarchy projectHierarchy)
public static Project GetProjectFromHierarchy(this IVsHierarchy projectHierarchy)
{
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
var result = projectHierarchy.GetProperty(
Expand All @@ -42,7 +42,7 @@ public static Project GetProjectFromHierarchy(IVsHierarchy projectHierarchy)
return (Project)projectObject;
}

public static string GetProjectFullPath(Project project)
public static string GetProjectFullPath(this Project project)
{
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
return project.Properties.Item("FullPath").Value.ToString();
Expand All @@ -65,7 +65,7 @@ public static string GetServiceFolderPath(this Project project, string rootFolde
return servicePath;
}

public static string GetSelectedPath(DTE2 dte)
public static string GetSelectedPath(this DTE2 dte)
{
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
var items = (Array)dte.ToolWindows.SolutionExplorer?.SelectedItems;
Expand Down
9 changes: 4 additions & 5 deletions src/Unchase.OData.ConnectedService/Handler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the Apache License 2.0. See License.txt in the project root for license information.

using System;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.ConnectedServices;
Expand All @@ -21,7 +20,7 @@ public override async Task<AddServiceInstanceResult> AddServiceInstanceAsync(Con

var codeGenInstance = (Instance)context.ServiceInstance;

var codeGenDescriptor = await GenerateCodeAsync(codeGenInstance.MetadataTempFilePath, codeGenInstance.ServiceConfig.EdmxVersion, context);
var codeGenDescriptor = await GenerateCodeAsync(codeGenInstance.ServiceConfig.EdmxVersion, context);

codeGenInstance.ServiceConfig.FunctionImports = null;
codeGenInstance.ServiceConfig.OperationImports = null;
Expand All @@ -39,7 +38,7 @@ public override async Task<UpdateServiceInstanceResult> UpdateServiceInstanceAsy

var codeGenInstance = (Instance)context.ServiceInstance;

var codeGenDescriptor = await GenerateCodeAsync(codeGenInstance.ServiceConfig.Endpoint, codeGenInstance.ServiceConfig.EdmxVersion, context);
var codeGenDescriptor = await GenerateCodeAsync(codeGenInstance.ServiceConfig.EdmxVersion, context);

codeGenInstance.ServiceConfig.FunctionImports = null;
codeGenInstance.ServiceConfig.OperationImports = null;
Expand All @@ -51,7 +50,7 @@ public override async Task<UpdateServiceInstanceResult> UpdateServiceInstanceAsy
return new UpdateServiceInstanceResult { GettingStartedDocument = new GettingStartedDocument(new Uri(codeGenDescriptor.ClientDocUri)) };
}

private static async Task<BaseCodeGenDescriptor> GenerateCodeAsync(string metadataUri, Version edmxVersion, ConnectedServiceHandlerContext context)
private static async Task<BaseCodeGenDescriptor> GenerateCodeAsync(Version edmxVersion, ConnectedServiceHandlerContext context)
{
var instance = (Instance)context.ServiceInstance;
BaseCodeGenDescriptor codeGenDescriptor;
Expand All @@ -68,7 +67,7 @@ private static async Task<BaseCodeGenDescriptor> GenerateCodeAsync(string metada
}
else
{
throw new Exception(string.Format(CultureInfo.InvariantCulture, "Not supported Edmx Version{0}", (edmxVersion != null ? $" {edmxVersion}." : ". Try with Endpoint ends \"/$metadata\".")));
throw new Exception($"Not supported Edmx Version{(edmxVersion != null ? $" {edmxVersion}." : ". Try with Endpoint ends \"/$metadata\".")}");
}

codeGenDescriptor.UseNetworkCredentials = instance.ServiceConfig.UseNetworkCredentials;
Expand Down
39 changes: 36 additions & 3 deletions src/Unchase.OData.ConnectedService/Models/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal class UserSettings

private const int MaxMruEntries = 10;

private ConnectedServiceLogger logger;
private ConnectedServiceLogger _logger;
#endregion

[DataMember]
Expand All @@ -37,6 +37,39 @@ internal class UserSettings

[DataMember]
public LanguageOption LanguageOption { get; set; }

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

[DataMember]
public string GeneratedFileNamePrefix { get; set; }

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

[DataMember]
public string NamespacePrefix { get; set; }

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

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

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

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

[DataMember]
public Constants.OperationImportsGenerator OperationImportsGenerator { get; set; }

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

[DataMember]
public string ExcludedOperationImportsNames { get; set; }
#endregion

#region Constructors
Expand All @@ -49,14 +82,14 @@ private UserSettings()
#region Methods
public void Save()
{
UserSettingsPersistenceHelper.Save(this, Constants.ProviderId, UserSettings.Name, null, this.logger);
UserSettingsPersistenceHelper.Save(this, Constants.ProviderId, UserSettings.Name, null, this._logger);
}

public static UserSettings Load(ConnectedServiceLogger logger)
{
var userSettings = UserSettingsPersistenceHelper.Load<UserSettings>(
Constants.ProviderId, UserSettings.Name, null, logger) ?? new UserSettings();
userSettings.logger = logger;
userSettings._logger = logger;

return userSettings;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Unchase.OData.ConnectedService/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: NeutralResourcesLanguage("en")]

2 changes: 1 addition & 1 deletion src/Unchase.OData.ConnectedService/Provider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Provider()
BitmapSizeOptions.FromWidthAndHeight(32, 32)
);
CreatedBy = Constants.Author;
Version = new Version(1, 2, 0, 0);
Version = new Version(1, 3, 0, 0);
Version = typeof(Provider).Assembly.GetName().Version;
MoreInfoUri = new Uri(Constants.Website);
}
Expand Down
Loading

0 comments on commit 74058cc

Please sign in to comment.