Skip to content

Commit 9d2445f

Browse files
Luke Owlclaw2Luke Owlclaw2
authored andcommitted
Merge branch 'master' into import_externals
2 parents f83c29d + d5fbddc commit 9d2445f

10 files changed

Lines changed: 162 additions & 16 deletions

File tree

.github/ISSUE_TEMPLATE.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
### Installed product versions
22
- Visual Studio: [example 2015 Professional]
33
- This extension: [example 1.1.21]
4+
- Options override:
5+
```
6+
[example {
7+
CamelCaseEnumerationValues = false,
8+
CamelCasePropertyNames = true,
9+
CamelCaseTypeNames = false,
10+
11+
WebEssentials2015 = false,
12+
13+
ClassInsteadOfInterface = false,
14+
DeclareModule = false,
15+
DefaultModuleName = "Server.Dtos",
16+
EOLType = EOLType.LF,
17+
IgnoreIntellisense = true,
18+
IndentTab = false,
19+
IndentTabSize = 2,
20+
UseNamespace = true,
21+
}]
22+
```
423

524
### Description
625
Replace this text with a short description
@@ -15,4 +34,4 @@ Replace this text with a short description
1534
Explain what it's doing and why it's wrong
1635

1736
### Expected behavior
18-
Explain what it should be doing after it's fixed.
37+
Explain what it should be doing after it's fixed.
-460 KB
Binary file not shown.

src/TypeScriptDefinitionGenerator/DtsPackage.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace TypeScriptDefinitionGenerator
1515
[ProvideMenuResource("Menus.ctmenu", 1)]
1616
[ProvideLanguageEditorOptionPage(typeof(OptionsDialogPage), "TypeScript", null, "Generate d.ts", null, new[] { "d.ts" })]
1717
[ProvideCodeGenerator(typeof(DtsGenerator), DtsGenerator.Name, DtsGenerator.Description, true)]
18-
[ProvideAutoLoad(PackageGuids.UIContextRuleString)]
18+
[ProvideAutoLoad(PackageGuids.UIContextRuleString, PackageAutoLoadFlags.BackgroundLoad)]
1919
[ProvideUIContextRule(PackageGuids.UIContextRuleString,
2020
name: "Auto load",
2121
expression: "cs | vb",
@@ -40,6 +40,8 @@ public static void EnsurePackageLoad()
4040

4141
protected override async Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
4242
{
43+
await JoinableTaskFactory.SwitchToMainThreadAsync();
44+
4345
Options = (OptionsDialogPage)GetDialogPage(typeof(OptionsDialogPage));
4446

4547
await ToggleCustomTool.InitializeAsync(this);

src/TypeScriptDefinitionGenerator/Generator/IntellisenseParser.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ private static bool IsPublic(CodeFunction cf)
201201
return retVal;
202202
}
203203

204+
private static string GetInterfaceName(CodeInterface cc)
205+
{
206+
return cc.Name;
207+
}
208+
204209
private static string GetClassName(CodeClass cc)
205210
{
206211
return cc.Name;
@@ -211,6 +216,16 @@ private static string GetEnumName(CodeEnum cc)
211216
return cc.Name;
212217
}
213218

219+
private static string GetNamespace(CodeInterface cc)
220+
{
221+
if (!Options.UseNamespace)
222+
return Options.DefaultModuleName;
223+
224+
return cc == null
225+
? Options.DefaultModuleName
226+
: cc.Namespace.FullName;
227+
}
228+
214229
private static string GetNamespace(CodeClass cc)
215230
{
216231
if (!Options.UseNamespace)
@@ -243,13 +258,16 @@ private static IntellisenseType GetType(CodeClass rootElement, CodeTypeRef codeT
243258

244259
if (isCollection)
245260
{
246-
isDictionary = codeTypeRef.AsString.StartsWith("System.Collections.Generic.Dictionary", StringComparison.Ordinal);
261+
isDictionary = codeTypeRef.AsString.StartsWith("System.Collections.Generic.Dictionary", StringComparison.Ordinal)
262+
|| codeTypeRef.AsString.StartsWith("System.Collections.Generic.IDictionary", StringComparison.Ordinal);
247263
}
248264

249265
string typeName = effectiveTypeRef.AsFullName;
250266

251267
try
252268
{
269+
//VSHelpers.WriteOnBuildDebugWindow($"%{(effectiveTypeRef.CodeType as CodeInterface2) != null}%");
270+
var codeInterface = effectiveTypeRef.CodeType as CodeInterface2;
253271
var codeClass = effectiveTypeRef.CodeType as CodeClass2;
254272
var codeEnum = effectiveTypeRef.CodeType as CodeEnum;
255273
var isPrimitive = IsPrimitive(effectiveTypeRef);
@@ -277,8 +295,10 @@ private static IntellisenseType GetType(CodeClass rootElement, CodeTypeRef codeT
277295
hasIntellisense = HasIntellisense(codeEnum.ProjectItem, references);
278296
}
279297

298+
//VSHelpers.WriteOnBuildDebugWindow($"@{codeClass != null}@{codeEnum != null}@{hasIntellisense}@{Options.DeclareModule}");
280299
result.ClientSideReferenceName = (codeClass != null && hasIntellisense ? (Options.DeclareModule ? GetNamespace(codeClass) + "." : "") + Utility.CamelCaseClassName(GetClassName(codeClass)) : null) ??
281-
(codeEnum != null && hasIntellisense ? (Options.DeclareModule ? GetNamespace(codeEnum) + "." : "") + Utility.CamelCaseClassName(GetEnumName(codeEnum)) : null);
300+
(codeEnum != null && hasIntellisense ? (Options.DeclareModule ? GetNamespace(codeEnum) + "." : "") + Utility.CamelCaseClassName(GetEnumName(codeEnum)) : null) ??
301+
(codeInterface != null && hasIntellisense ? (Options.DeclareModule ? GetNamespace(codeInterface) + "." : "") + Utility.CamelCaseClassName(GetInterfaceName(codeInterface)) : null);
282302
}
283303

284304
if (!isPrimitive && (codeClass != null || codeEnum != null) && !traversedTypes.Contains(effectiveTypeRef.CodeType.FullName) && !isCollection)

src/TypeScriptDefinitionGenerator/Generator/IntellisenseType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ private string GetTargetName(string codeName, bool js)
6868
return "Date";
6969

7070
case "guid":
71+
case "system.guid":
7172
case "string":
7273
return js ? "String" : "string";
7374

src/TypeScriptDefinitionGenerator/TypeScriptDefinitionGenerator.csproj

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@
107107
<Private>False</Private>
108108
</Reference>
109109
<Reference Include="Microsoft.CSharp" />
110-
<Reference Include="Microsoft.Diagnostics.Tracing.EventSource, Version=1.1.16.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
111-
<HintPath>..\..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.16-beta\lib\net45\Microsoft.Diagnostics.Tracing.EventSource.dll</HintPath>
110+
<Reference Include="Microsoft.Diagnostics.Tracing.EventSource, Version=1.1.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
111+
<HintPath>..\..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.28\lib\net46\Microsoft.Diagnostics.Tracing.EventSource.dll</HintPath>
112112
</Reference>
113113
<Reference Include="Microsoft.VisualStudio.CommandBars, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
114114
<EmbedInteropTypes>False</EmbedInteropTypes>
@@ -131,7 +131,7 @@
131131
<Private>True</Private>
132132
</Reference>
133133
<Reference Include="Microsoft.VisualStudio.RemoteControl, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
134-
<HintPath>..\..\packages\Microsoft.VisualStudio.RemoteControl.14.0.263-masterA66FF384\lib\net45\Microsoft.VisualStudio.RemoteControl.dll</HintPath>
134+
<HintPath>..\..\packages\Microsoft.VisualStudio.RemoteControl.14.1.2\lib\net45\Microsoft.VisualStudio.RemoteControl.dll</HintPath>
135135
</Reference>
136136
<Reference Include="Microsoft.VisualStudio.Shell.15.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
137137
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.15.0.15.4.27004\lib\Microsoft.VisualStudio.Shell.15.0.dll</HintPath>
@@ -174,7 +174,7 @@
174174
<Private>False</Private>
175175
</Reference>
176176
<Reference Include="Microsoft.VisualStudio.Telemetry, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
177-
<HintPath>..\..\packages\Microsoft.VisualStudio.Telemetry.15.8.950-master0B174108\lib\net45\Microsoft.VisualStudio.Telemetry.dll</HintPath>
177+
<HintPath>..\..\packages\Microsoft.VisualStudio.Telemetry.15.8.956\lib\net45\Microsoft.VisualStudio.Telemetry.dll</HintPath>
178178
</Reference>
179179
<Reference Include="Microsoft.VisualStudio.Text.Data, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
180180
<HintPath>..\..\packages\Microsoft.VisualStudio.Text.Data.15.4.27004\lib\net45\Microsoft.VisualStudio.Text.Data.dll</HintPath>
@@ -224,7 +224,7 @@
224224
<Private>True</Private>
225225
</Reference>
226226
<Reference Include="Microsoft.VisualStudio.Utilities.Internal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
227-
<HintPath>..\..\packages\Microsoft.VisualStudio.Utilities.Internal.14.0.79-master7F49A4E3\lib\net45\Microsoft.VisualStudio.Utilities.Internal.dll</HintPath>
227+
<HintPath>..\..\packages\Microsoft.VisualStudio.Utilities.Internal.14.1.2\lib\net45\Microsoft.VisualStudio.Utilities.Internal.dll</HintPath>
228228
</Reference>
229229
<Reference Include="Microsoft.VisualStudio.Validation, Version=15.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
230230
<HintPath>..\..\packages\Microsoft.VisualStudio.Validation.15.3.32\lib\net45\Microsoft.VisualStudio.Validation.dll</HintPath>
@@ -287,11 +287,9 @@
287287
<Error Condition="!Exists('..\..\packages\Microsoft.VSSDK.BuildTools.15.5.72\build\Microsoft.VSSDK.BuildTools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.VSSDK.BuildTools.15.5.72\build\Microsoft.VSSDK.BuildTools.props'))" />
288288
<Error Condition="!Exists('..\..\packages\Microsoft.VSSDK.BuildTools.15.5.72\build\Microsoft.VSSDK.BuildTools.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.VSSDK.BuildTools.15.5.72\build\Microsoft.VSSDK.BuildTools.targets'))" />
289289
<Error Condition="!Exists('..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.15.7.17\build\Microsoft.VisualStudio.Threading.Analyzers.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.15.7.17\build\Microsoft.VisualStudio.Threading.Analyzers.targets'))" />
290-
<Error Condition="!Exists('..\..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.16-beta\build\portable-net45+win8+wpa81\Microsoft.Diagnostics.Tracing.EventSource.Redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.16-beta\build\portable-net45+win8+wpa81\Microsoft.Diagnostics.Tracing.EventSource.Redist.targets'))" />
291290
</Target>
292291
<Import Project="..\..\packages\Microsoft.VSSDK.BuildTools.15.5.72\build\Microsoft.VSSDK.BuildTools.targets" Condition="Exists('..\..\packages\Microsoft.VSSDK.BuildTools.15.5.72\build\Microsoft.VSSDK.BuildTools.targets')" />
293292
<Import Project="..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.15.7.17\build\Microsoft.VisualStudio.Threading.Analyzers.targets" Condition="Exists('..\..\packages\Microsoft.VisualStudio.Threading.Analyzers.15.7.17\build\Microsoft.VisualStudio.Threading.Analyzers.targets')" />
294-
<Import Project="..\..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.16-beta\build\portable-net45+win8+wpa81\Microsoft.Diagnostics.Tracing.EventSource.Redist.targets" Condition="Exists('..\..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.16-beta\build\portable-net45+win8+wpa81\Microsoft.Diagnostics.Tracing.EventSource.Redist.targets')" />
295293
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
296294
Other similar extension points exist, see Microsoft.Common.targets.
297295
<Target Name="BeforeBuild">

src/TypeScriptDefinitionGenerator/app.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
77
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
88
</dependentAssembly>
9+
<dependentAssembly>
10+
<assemblyIdentity name="Microsoft.Diagnostics.Tracing.EventSource" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
11+
<bindingRedirect oldVersion="0.0.0.0-1.1.28.0" newVersion="1.1.28.0" />
12+
</dependentAssembly>
913
</assemblyBinding>
1014
</runtime>
1115
</configuration>

src/TypeScriptDefinitionGenerator/packages.config

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.Diagnostics.Tracing.EventSource.Redist" version="1.1.16-beta" targetFramework="net462" />
3+
<package id="Microsoft.Diagnostics.Tracing.EventSource.Redist" version="1.1.28" targetFramework="net462" />
44
<package id="Microsoft.VisualStudio.CoreUtility" version="15.4.27004" targetFramework="net46" />
55
<package id="Microsoft.VisualStudio.Editor" version="15.4.27004" targetFramework="net46" />
66
<package id="Microsoft.VisualStudio.Imaging" version="15.4.27004" targetFramework="net462" />
77
<package id="Microsoft.VisualStudio.OLE.Interop" version="7.10.6071" targetFramework="net462" />
8-
<package id="Microsoft.VisualStudio.RemoteControl" version="14.0.263-masterA66FF384" targetFramework="net462" />
8+
<package id="Microsoft.VisualStudio.RemoteControl" version="14.1.2" targetFramework="net462" />
99
<package id="Microsoft.VisualStudio.SDK.Analyzers" version="15.7.4" targetFramework="net462" />
1010
<package id="Microsoft.VisualStudio.SDK.EmbedInteropTypes" version="15.0.12" targetFramework="net462" />
1111
<package id="Microsoft.VisualStudio.Shell.15.0" version="15.4.27004" targetFramework="net462" />
@@ -17,7 +17,7 @@
1717
<package id="Microsoft.VisualStudio.Shell.Interop.15.3.DesignTime" version="15.0.26606" targetFramework="net462" />
1818
<package id="Microsoft.VisualStudio.Shell.Interop.8.0" version="8.0.50727" targetFramework="net46" />
1919
<package id="Microsoft.VisualStudio.Shell.Interop.9.0" version="9.0.30729" targetFramework="net46" />
20-
<package id="Microsoft.VisualStudio.Telemetry" version="15.8.950-master0B174108" targetFramework="net462" />
20+
<package id="Microsoft.VisualStudio.Telemetry" version="15.8.956" targetFramework="net462" />
2121
<package id="Microsoft.VisualStudio.Text.Data" version="15.4.27004" targetFramework="net46" />
2222
<package id="Microsoft.VisualStudio.Text.Logic" version="15.4.27004" targetFramework="net46" />
2323
<package id="Microsoft.VisualStudio.Text.UI" version="15.4.27004" targetFramework="net46" />
@@ -31,7 +31,7 @@
3131
<package id="Microsoft.VisualStudio.Threading" version="15.4.4" targetFramework="net462" />
3232
<package id="Microsoft.VisualStudio.Threading.Analyzers" version="15.7.17" targetFramework="net462" />
3333
<package id="Microsoft.VisualStudio.Utilities" version="15.4.27004" targetFramework="net462" />
34-
<package id="Microsoft.VisualStudio.Utilities.Internal" version="14.0.79-master7F49A4E3" targetFramework="net462" />
34+
<package id="Microsoft.VisualStudio.Utilities.Internal" version="14.1.2" targetFramework="net462" />
3535
<package id="Microsoft.VisualStudio.Validation" version="15.3.32" targetFramework="net462" />
3636
<package id="Microsoft.VSSDK.BuildTools" version="15.5.72" targetFramework="net462" developmentDependency="true" />
3737
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net46" />

tests/ClassLibrary1/SomeSomeClass.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ public class SomeSomeClass: SomeClass
1616
public IEnumerable<int> Inc10 { get; set; }
1717
public int[] Inc11 { get; set; }
1818
public bool Inc12 { get; set; }
19+
public Dictionary<string, int> Inc13 { get; set; }
20+
public IDictionary<string, int> Inc14 { get; set; }
1921
}
2022
}

0 commit comments

Comments
 (0)