Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="Provider.cs" />
<Compile Include="Utilities\ProjectHelper.cs" />
<Compile Include="ViewModels\ServiceEndpointWizardPage.cs" />
Expand All @@ -67,6 +72,11 @@
<Compile Include="Wizard.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Include="source.extension.vsixmanifest">
<SubType>Designer</SubType>
</None>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/OpenApiConnectedService.Package/Properties/Settings.settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="OpenApiConnectedService.Package.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="ServiceName" Type="System.String" Scope="User">
<Value Profile="(Default)">MyService</Value>
</Setting>
<Setting Name="ServiceUri" Type="System.String" Scope="User">
<Value Profile="(Default)">https://petstore.swagger.io/v2/swagger.json</Value>
</Setting>
</Settings>
</SettingsFile>
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Microsoft.VisualStudio.ConnectedServices;
using OpenApiConnectedService.Package.Properties;

namespace OpenApiConnectedService.Package.ViewModels
{
Expand Down Expand Up @@ -44,8 +47,8 @@ public ServiceEndpointWizardPage(ConnectedServiceProviderContext context)
Title = Constants.ExtensionName;
Description = "Specify the service to add";
Legend = "Service Endpoint";
ServiceName = "MyService";
ServiceUri = "https://petstore.swagger.io/v2/swagger.json";
ServiceName = Settings.Default.ServiceName;
ServiceUri = Settings.Default.ServiceUri;

View = new Views.ServiceEndpointWizardPageView
{
Expand Down Expand Up @@ -83,6 +86,16 @@ private bool IsPageConfigured()
{
if (string.IsNullOrEmpty(ServiceName)) return false;
if (!Uri.TryCreate(ServiceUri, UriKind.Absolute, out Uri uri)) return false;

try
{
CodeGenerator.ValidateIdentifiers(new CodeNamespace(ServiceName));
}
catch(ArgumentException)
{
return false;
}

return true;
}

Expand Down
18 changes: 18 additions & 0 deletions src/OpenApiConnectedService.Package/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="OpenApiConnectedService.Package.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<OpenApiConnectedService.Package.Properties.Settings>
<setting name="ServiceName" serializeAs="String">
<value>MyService</value>
</setting>
<setting name="ServiceUri" serializeAs="String">
<value>https://petstore.swagger.io/v2/swagger.json</value>
</setting>
</OpenApiConnectedService.Package.Properties.Settings>
</userSettings>
</configuration>