forked from VsVim/VsVim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest-ProjectFiles.ps1
159 lines (144 loc) · 5.4 KB
/
Test-ProjectFiles.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
###############################################################################
#
# This script is used to validate projects don't inadvertently reference a
# DLL which isn't legal for the set of Visual Studio versions they project
# must work in
#
###############################################################################
$script:scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
$script:projectFiles = @{
"EditorUtils.csproj" = "all";
"EditorUtilsTest.csproj" = "test";
"VimCore.fsproj" = "all";
"VimCoreTest.csproj" = "test";
"VimWpf.csproj" = "all";
"VimWpfTest.csproj" = "test";
"VsVimShared.csproj" = "all";
"VsVimSharedTest.csproj" = "test";
"VsVim.csproj" = "all";
"VsVim10.csproj" = "all";
"VsVim11.csproj" = "all";
"VsVimDev10.csproj" = "Dev10";
"VsVimDev11.csproj" = "Dev11";
}
# Assemblies valid in any version. These are all versioned assemblies and
# must either be BCL types or types which are explicitly versioned in the
# devenv.exe.config file
#
# Note: The Shell.XXX assemblies are all COM assemblies that aren't versioned
# but their COM so they don't change either. Fine to reference from any
# version after the one they were defined in
$script:listAll = @(
"envdte=8.0.0.0",
"envdte80=8.0.0.0",
"envdte90=9.0.0.0",
"envdte100=10.0.0.0",
"FSharp.Core=4.0.0.0",
"Microsoft.VisualStudio.CoreUtility=10.0.0.0",
"Microsoft.VisualStudio.Editor=10.0.0.0",
"Microsoft.VisualStudio.OLE.Interop=7.1.40304.0"
"Microsoft.VisualStudio.Language.Intellisense=10.0.0.0",
"Microsoft.VisualStudio.Language.StandardClassification=10.0.0.0",
"Microsoft.VisualStudio.Shell=2.0.0.0",
"Microsoft.VisualStudio.Shell.10.0=10.0.0.0",
"Microsoft.VisualStudio.Shell.Immutable.10.0=10.0.0.0",
"Microsoft.VisualStudio.Shell.Interop=7.1.40304.0",
"Microsoft.VisualStudio.Shell.Interop.8.0=8.0.0.0",
"Microsoft.VisualStudio.Shell.Interop.9.0=9.0.0.0",
"Microsoft.VisualStudio.Shell.Interop.10.0=10.0.0.0",
"Microsoft.VisualStudio.Text.Logic=10.0.0.0",
"Microsoft.VisualStudio.Text.Data=10.0.0.0",
"Microsoft.VisualStudio.Text.UI=10.0.0.0",
"Microsoft.VisualStudio.Text.UI.Wpf=10.0.0.0",
"Microsoft.VisualStudio.TextManager.Interop=7.1.40304.0",
"Microsoft.VisualStudio.TextManager.Interop.8.0=8.0.0.0",
"Microsoft.VisualStudio.Platform.VSEditor.Interop=10.0.0.0",
"mscorlib=",
"PresentationCore="
"PresentationFramework="
"System=",
"System.ComponentModel.Composition=",
"System.Core=",
"System.Data="
"System.Drawing="
"System.Xml=",
"System.Xaml=",
"WindowsBase="
)
# Types specific to Dev10
$script:list10 = @(
"Microsoft.VisualStudio.Platform.WindowManagement=10.0.0.0",
"Microsoft.VisualStudio.Shell.ViewManager=10.0.0.0"
)
$script:list10 = $list10 + $listAll
# Types specific to Dev11
$script:list11 = @(
"Microsoft.VisualStudio.Platform.WindowManagement=11.0.0.0",
"Microsoft.VisualStudio.Shell.11.0=11.0.0.0",
"Microsoft.VisualStudio.Shell.ViewManager=11.0.0.0"
)
$script:list11 = $list11 + $listAll
# Test assemblies are allowed to reference a couple of DLL's needed
# to host the editor but aren't legal / recomended for noraml
# code. These DLL's don't version and should be accessed instead
# through other interfaces
$script:listTest = @(
"Microsoft.VisualStudio.Platform.VSEditor=10.0.0.0",
"Moq=4.0.10827.0",
"nunit.framework=2.6.0.12051"
)
$script:listTest = $listTest + $listAll + $list10
function Test-Reference() {
param ([string]$dll = $(throw "Need a dll name to check"),
$list = $(throw "Need a target list"))
foreach ($validDll in $list) {
if ($validDll -eq $dll) {
return $true;
}
}
return $false;
}
function Test-Include() {
param ([string]$project = $(throw "Need a project string"),
[string]$reference = $(throw "Need a reference string"),
$list = $(throw "Need a target list"))
if (-not ($reference -match "^[^,]*")) {
write-error "Invalid reference: $reference"
}
$dll = $matches[0];
$version = "";
if ($reference -match "Version=([\d.]+)") {
$version = $matches[1]
}
$dll = "{0}={1}" -f $dll, $version;
if (-not (Test-Reference $dll $list)) {
write-host "Invalid reference $dll in $project"
}
}
function Test-ProjectFile() {
param ([string]$path = $(throw "Need a project file path"),
$list = $(throw "Need a target list"))
$count = 0;
$name = split-path -leaf $path
write-host "Checking $name"
foreach ($line in gc $path) {
if ($line -match "<Reference Include=`"([^`"]*)`"") {
Test-Include $name $matches[1] $list
$count += 1
}
}
if ($count -eq 0) {
write-error "Couldn't find any references: $path"
}
}
foreach ($projectFile in gci -re -in *proj) {
$name = $projectFile.Name
$fullName = $projectFile.FullName
switch ($projectFiles[$name]) {
"all" { Test-ProjectFile $fullName $listAll }
"test" { Test-ProjectFile $fullName $listTest }
"Dev10" { Test-ProjectFile $fullName $list10 }
"Dev11" { Test-ProjectFile $fullName $list11 }
default { write-error "Unrecognized file: $name" }
}
}