Skip to content

Commit 9ea51fc

Browse files
committed
Added xml schemas to project if not installed in global schema cache.
1 parent dcd7eb0 commit 9ea51fc

File tree

6 files changed

+6779
-0
lines changed

6 files changed

+6779
-0
lines changed

ExcelDNAVSExtension/ExcelDNAVSExtension/ExcelDNAVSExtension.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<DefineConstants>DEBUG;TRACE</DefineConstants>
4242
<ErrorReport>prompt</ErrorReport>
4343
<WarningLevel>4</WarningLevel>
44+
<NoWarn>VSTHRD010</NoWarn>
4445
</PropertyGroup>
4546
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
4647
<DebugType>pdbonly</DebugType>
@@ -49,11 +50,13 @@
4950
<DefineConstants>TRACE</DefineConstants>
5051
<ErrorReport>prompt</ErrorReport>
5152
<WarningLevel>4</WarningLevel>
53+
<NoWarn>VSTHRD010</NoWarn>
5254
</PropertyGroup>
5355
<ItemGroup>
5456
<Compile Include="Properties\AssemblyInfo.cs" />
5557
<Compile Include="TemplateWizard.cs" />
5658
<Compile Include="VSPackage.cs" />
59+
<Compile Include="XmlSchemas.cs" />
5760
</ItemGroup>
5861
<ItemGroup>
5962
<Content Include="Packages\exceldna.addin.1.1.1.nupkg">
@@ -64,6 +67,9 @@
6467
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
6568
<IncludeInVSIX>true</IncludeInVSIX>
6669
</Content>
70+
<Content Include="XmlSchemas\*.*">
71+
<IncludeInVSIX>true</IncludeInVSIX>
72+
</Content>
6773
<Content Include="Resources\VSPackage.ico" />
6874
<None Include="Key.snk" />
6975
<None Include="source.extension.vsixmanifest">

ExcelDNAVSExtension/ExcelDNAVSExtension/TemplateWizard.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public void BeforeOpeningFile(ProjectItem projectItem)
1212

1313
public void ProjectFinishedGenerating(Project project)
1414
{
15+
XmlSchemas.AddSchemasToProject(project);
1516
}
1617

1718
public void ProjectItemFinishedGenerating(ProjectItem projectItem)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.IO;
2+
3+
namespace ExcelDNAVSExtension
4+
{
5+
class XmlSchemas
6+
{
7+
public static void AddSchemasToProject(EnvDTE.Project project)
8+
{
9+
string schemasDir = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "XmlSchemas");
10+
foreach (string file in Directory.GetFiles(schemasDir))
11+
{
12+
if (!IsSchemaInCache(Path.GetFileName(file), project.DTE.LocaleID))
13+
project.ProjectItems.AddFromFileCopy(file);
14+
}
15+
}
16+
17+
private static bool IsSchemaInCache(string fileName, int locale)
18+
{
19+
string schemaCacheDir = Path.Combine(Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName), @"..\..\Xml\Schemas");
20+
return File.Exists(Path.Combine(schemaCacheDir, fileName)) || File.Exists(Path.Combine(schemaCacheDir, locale.ToString(), fileName));
21+
}
22+
}
23+
}
Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<xs:schema id="dna"
3+
targetNamespace="http://schemas.excel-dna.net/addin/2018/05/dnalibrary"
4+
attributeFormDefault="unqualified"
5+
elementFormDefault="qualified"
6+
xmlns="http://schemas.excel-dna.net/addin/2018/05/dnalibrary"
7+
xmlns:mstns="http://schemas.excel-dna.net/addin/2018/05/dnalibrary"
8+
xmlns:xs="http://www.w3.org/2001/XMLSchema">
9+
10+
<xs:simpleType name="Boolean">
11+
<xs:union>
12+
<xs:simpleType>
13+
<!-- Intellisense suggestions -->
14+
<xs:restriction base="xs:string">
15+
<xs:enumeration value="true" />
16+
<xs:enumeration value="false" />
17+
</xs:restriction>
18+
</xs:simpleType>
19+
<xs:simpleType>
20+
<!-- Other allowed values (but hidden from Intellisense) -->
21+
<xs:restriction base="xs:string">
22+
<xs:pattern value="[Tt]rue" />
23+
<xs:pattern value="[Ff]alse" />
24+
<xs:pattern value="0" />
25+
<xs:pattern value="1" />
26+
</xs:restriction>
27+
</xs:simpleType>
28+
</xs:union>
29+
</xs:simpleType>
30+
31+
<xs:simpleType name="RuntimeVersionType">
32+
<xs:union>
33+
<xs:simpleType>
34+
<!-- Intellisense suggestions -->
35+
<xs:restriction base="xs:string">
36+
<xs:enumeration value="v2.0" />
37+
<xs:enumeration value="v4.0" />
38+
</xs:restriction>
39+
</xs:simpleType>
40+
<xs:simpleType>
41+
<!-- Other allowed values (but hidden from Intellisense) -->
42+
<xs:restriction base="xs:string">
43+
<xs:pattern value="v2.0.50727" />
44+
<xs:pattern value="v4.0.30319" />
45+
</xs:restriction>
46+
</xs:simpleType>
47+
</xs:union>
48+
</xs:simpleType>
49+
50+
<xs:simpleType name="LanguageType">
51+
<xs:union>
52+
<xs:simpleType>
53+
<!-- Intellisense suggestions -->
54+
<xs:restriction base="xs:string">
55+
<xs:enumeration value="C#" />
56+
<xs:enumeration value="VB" />
57+
<xs:enumeration value="F#" />
58+
</xs:restriction>
59+
</xs:simpleType>
60+
<xs:simpleType>
61+
<!-- Other allowed values (but hidden from Intellisense) -->
62+
<xs:restriction base="xs:string">
63+
<xs:pattern value="(CS|cs)" />
64+
<xs:pattern value="(CSHARP|CSharp|csharp)" />
65+
<xs:pattern value="(C#|c#)" />
66+
<xs:pattern value="(VB|vb)" />
67+
<xs:pattern value="(VISUAL BASIC|Visual Basic)" />
68+
<xs:pattern value="(VISUALBASIC|VisualBasic)" />
69+
<xs:pattern value="(FS|fs)" />
70+
<xs:pattern value="(F#|f#)" />
71+
<xs:pattern value="(FSHARP|FSharp|fsharp)" />
72+
<xs:pattern value="(F SHARP|F Sharp|f sharp)" />
73+
</xs:restriction>
74+
</xs:simpleType>
75+
</xs:union>
76+
</xs:simpleType>
77+
78+
<xs:complexType name="ExternalLibraryType">
79+
<xs:simpleContent>
80+
<xs:extension base="xs:string">
81+
<xs:attribute name="Path"
82+
use="required"
83+
type="xs:string" />
84+
<xs:attribute name="TypeLibPath"
85+
use="optional"
86+
type="xs:string" />
87+
<xs:attribute name="ComServer"
88+
use="optional"
89+
type="Boolean" />
90+
<xs:attribute name="Pack"
91+
use="optional"
92+
type="Boolean" />
93+
<xs:attribute name="LoadFromBytes"
94+
use="optional"
95+
type="Boolean" />
96+
<xs:attribute name="ExplicitExports"
97+
use="optional"
98+
type="Boolean" />
99+
<xs:attribute name="ExplicitRegistration"
100+
use="optional"
101+
type="Boolean" />
102+
<xs:attribute name="UseVersionAsOutputVersion"
103+
use="optional"
104+
type="Boolean" />
105+
<xs:attribute name="IncludePdb"
106+
use="optional"
107+
type="Boolean" />
108+
</xs:extension>
109+
</xs:simpleContent>
110+
</xs:complexType>
111+
112+
<xs:complexType name="SourceItemType"
113+
mixed="true">
114+
<xs:simpleContent>
115+
<xs:extension base="xs:string">
116+
<xs:attribute name="Name"
117+
use="optional"
118+
type="xs:string" />
119+
<xs:attribute name="Path"
120+
use="optional"
121+
type="xs:string" />
122+
<xs:attribute name="Pack"
123+
use="optional"
124+
type="Boolean" />
125+
</xs:extension>
126+
</xs:simpleContent>
127+
</xs:complexType>
128+
129+
<xs:complexType name="ProjectType"
130+
mixed="true">
131+
<xs:sequence>
132+
<xs:choice
133+
minOccurs="0"
134+
maxOccurs="unbounded">
135+
<xs:element name="Reference"
136+
maxOccurs="unbounded"
137+
minOccurs="0"
138+
type="ReferenceType">
139+
</xs:element>
140+
<xs:element name="SourceItem"
141+
maxOccurs="unbounded"
142+
minOccurs="0"
143+
type="SourceItemType">
144+
</xs:element>
145+
</xs:choice>
146+
</xs:sequence>
147+
<xs:attribute name="Name"
148+
use="optional"
149+
type="xs:string" />
150+
<xs:attribute name="Language"
151+
use="optional"
152+
type="LanguageType" />
153+
<xs:attribute name="CompilerVersion"
154+
use="optional"
155+
type="xs:string" />
156+
<xs:attribute name="DefaultReferences"
157+
use="optional"
158+
type="Boolean" />
159+
<xs:attribute name="DefaultImports"
160+
use="optional"
161+
type="Boolean" />
162+
<xs:attribute name="ExplicitExports"
163+
use="optional"
164+
type="Boolean" />
165+
<xs:attribute name="ExplicitRegistration"
166+
use="optional"
167+
type="Boolean" />
168+
<xs:attribute name="ComServer"
169+
use="optional"
170+
type="Boolean" />
171+
</xs:complexType>
172+
173+
<xs:complexType name="ReferenceType">
174+
<xs:simpleContent>
175+
<xs:extension base="xs:string">
176+
<xs:attribute name="Name"
177+
use="optional"
178+
type="xs:string" />
179+
<xs:attribute name="Path"
180+
use="optional"
181+
type="xs:string" />
182+
<xs:attribute name="AssemblyPath"
183+
use="optional"
184+
type="xs:string" />
185+
<xs:attribute name="Pack"
186+
use="optional"
187+
type="Boolean" />
188+
<xs:attribute name="IncludePdb"
189+
use="optional"
190+
type="Boolean" />
191+
</xs:extension>
192+
</xs:simpleContent>
193+
</xs:complexType>
194+
195+
<xs:complexType name="ImageType">
196+
<xs:simpleContent>
197+
<xs:extension base="xs:string">
198+
<xs:attribute name="Name"
199+
use="required"
200+
type="xs:string" />
201+
<xs:attribute name="Path"
202+
use="required"
203+
type="xs:string" />
204+
<xs:attribute name="Pack"
205+
use="optional"
206+
type="Boolean" />
207+
</xs:extension>
208+
</xs:simpleContent>
209+
</xs:complexType>
210+
211+
<xs:complexType name="CustomUIType">
212+
<xs:sequence>
213+
<xs:any maxOccurs="unbounded"
214+
minOccurs="0"
215+
processContents="lax" />
216+
</xs:sequence>
217+
</xs:complexType>
218+
219+
<xs:complexType name="DnaLibraryType"
220+
mixed="true">
221+
<xs:sequence>
222+
<xs:choice
223+
minOccurs="0"
224+
maxOccurs="unbounded">
225+
<xs:element name="ExternalLibrary"
226+
maxOccurs="unbounded"
227+
minOccurs="0"
228+
type="ExternalLibraryType">
229+
</xs:element>
230+
<xs:element name="Project"
231+
maxOccurs="unbounded"
232+
minOccurs="0"
233+
type="ProjectType">
234+
</xs:element>
235+
<xs:element name="Reference"
236+
maxOccurs="unbounded"
237+
minOccurs="0"
238+
type="ReferenceType">
239+
</xs:element>
240+
<xs:element name="Image"
241+
maxOccurs="unbounded"
242+
minOccurs="0"
243+
type="ImageType">
244+
</xs:element>
245+
<xs:element name="CustomUI"
246+
maxOccurs="unbounded"
247+
minOccurs="0"
248+
type="CustomUIType">
249+
</xs:element>
250+
</xs:choice>
251+
</xs:sequence>
252+
<xs:attribute name="Name"
253+
use="optional"
254+
type="xs:string" />
255+
<xs:attribute name="RuntimeVersion"
256+
use="optional"
257+
type="RuntimeVersionType" />
258+
<xs:attribute name="ShadowCopyFiles"
259+
use="optional"
260+
type="Boolean" />
261+
<xs:attribute name="CreateSandboxedAppDomain"
262+
use="optional"
263+
type="Boolean" />
264+
<xs:attribute name="Language"
265+
use="optional"
266+
type="LanguageType" />
267+
<xs:attribute name="CompilerVersion"
268+
use="optional"
269+
type="xs:string" />
270+
<xs:attribute name="DefaultReferences"
271+
use="optional"
272+
type="Boolean" />
273+
<xs:attribute name="DefaultImports"
274+
use="optional"
275+
type="Boolean" />
276+
</xs:complexType>
277+
278+
<xs:element name="DnaLibrary"
279+
type="DnaLibraryType" />
280+
281+
</xs:schema>

0 commit comments

Comments
 (0)