-
Notifications
You must be signed in to change notification settings - Fork 414
Expand file tree
/
Copy pathApplicationPropertyPage.cs
More file actions
257 lines (234 loc) · 11.5 KB
/
ApplicationPropertyPage.cs
File metadata and controls
257 lines (234 loc) · 11.5 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE.md file in the project root for more information.
using System;
using System.Collections.Generic;
using Microsoft.Build.Framework.XamlTypes;
using Microsoft.VisualStudio.ProjectSystem.Properties;
using PPR = Microsoft.VisualStudio.ProjectSystem.Rules.PropertyPages.PropertyPageResources;
namespace Microsoft.VisualStudio.ProjectSystem.Rules.PropertyPages
{
internal static class PropertyMetadata
{
public static readonly string VisibilityCondition = "VisibilityCondition";
public static readonly string SearchTerms = "SearchTerms";
public static readonly string DependsOn = "DependsOn";
}
// TODO: The context could come from a constant.
[ExportRuleObjectProvider(name: "DefaultApplicationPropertyPageProvider", context: "Project")]
[AppliesTo(ProjectCapability.CSharpOrVisualBasicOrFSharp)]
[Order(Order.Default)]
internal sealed class ApplicationPropertyPageProvider : IRuleObjectProvider
{
private const string GeneralCategoryName = "General";
private const string ResourcesCategoryName = "Resources";
private const string PackagingCategoryName = "Packaging";
private readonly Lazy<List<Rule>> _rules = new(CreateRules);
private static List<Rule> CreateRules()
{
Rule rule = new();
rule.BeginInit();
rule.Name = "Application";
rule.Description = PPR.ApplicationPage_Description;
rule.DisplayName = PPR.ApplicationPage_DisplayName;
// TODO: The PageTemplate could come from a constant.
rule.PageTemplate = "generic";
rule.Order = 100;
rule.Categories = new()
{
CreateCategory(
name: GeneralCategoryName,
displayName: PPR.ApplicationPage_GeneralCategory_DisplayName,
description: PPR.ApplicationPage_GeneralCategory_Description),
CreateCategory(
name: ResourcesCategoryName,
displayName: PPR.ApplicationPage_ResourcesCategory_DisplayName,
description: PPR.ApplicationPage_ResourcesCategory_Description),
CreateCategory(
name: PackagingCategoryName,
displayName: PPR.ApplicationPage_PackagingCategory_DisplayName,
description: PPR.ApplicationPage_PackagingCategory_Description)
};
rule.DataSource = new()
{
// TODO: The Persistence could come from a constant.
Persistence = "ProjectFile",
SourceOfDefaultValue = DefaultValueSourceLocation.AfterContext,
HasConfigurationCondition = false
};
EnumProperty outputTypeProperty = new()
{
Name = "OutputType",
DisplayName = PPR.ApplicationPage_OutputTypeProperty_DisplayName,
Description = PPR.ApplicationPage_OutputTypeProperty_Description,
Category = GeneralCategoryName,
AdmissibleValues =
{
new() { Name = "Library", DisplayName = PPR.ApplicationPage_OutputTypeProperty_LibraryValue_DisplayName },
new() { Name = "Exe", DisplayName = PPR.ApplicationPage_OutputTypeProperty_ExeValue_DisplayName },
new() { Name = "WinExe", DisplayName = PPR.ApplicationPage_OutputTypeProperty_WinExeValue_DisplayName }
}
};
BoolProperty targetMultipleFrameworksProperty = new()
{
Name = "TargetMultipleFrameworks",
DisplayName = PPR.ApplicationPage_TargetMultipleFrameworksProperty_DisplayName,
Description = PPR.ApplicationPage_TargetMultipleFrameworksProperty_Description,
HelpUrl = "https://go.microsoft.com/fwlink/?linkid=2147236",
Category = GeneralCategoryName,
Visible = false,
DataSource = new()
{
Persistence = "ProjectFileWithInterception",
HasConfigurationCondition = false
}
};
DynamicEnumProperty interceptedTargetFrameworkProperty = new()
{
Name = "InterceptedTargetFramework",
DisplayName = PPR.ApplicationPage_InterceptedTargetFrameworkProperty_DisplayName,
Description = PPR.ApplicationPage_InterceptedTargetFrameworkProperty_Description,
HelpUrl = "https://go.microsoft.com/fwlink/?linkid=2147236",
Category = GeneralCategoryName,
EnumProvider = "SupportedTargetFrameworksEnumProvider",
MultipleValuesAllowed = false,
DataSource = new()
{
Persistence = "ProjectFileWithInterception",
HasConfigurationCondition = false
},
Metadata =
{
new() { Name = PropertyMetadata.VisibilityCondition, Value = "(not (has-evaluated-value \"Application\" \"TargetMultipleFrameworks\" true))" },
new() { Name = PropertyMetadata.SearchTerms, Value = PPR.ApplicationPage_InterceptedTargetFrameworkProperty_SearchTerms },
new() { Name = PropertyMetadata.DependsOn, Value = "Application::TargetMultipleFrameworks" }
}
};
StringProperty targetFrameworksProperty = new()
{
Name = "TargetFrameworks",
DisplayName = PPR.ApplicationPage_TargetFrameworksProperty_DisplayName,
Description = PPR.ApplicationPage_TargetFrameworksProperty_Description,
HelpUrl = "https://go.microsoft.com/fwlink/?linkid=2147236",
Category = GeneralCategoryName,
DataSource = new()
{
Persistence = "ProjectFileWithInterception",
HasConfigurationCondition = false
},
Metadata =
{
new() { Name = PropertyMetadata.VisibilityCondition, Value = "(has-evaluated-value \"Application\" \"TargetMultipleFrameworks\" true)" },
new() { Name = PropertyMetadata.SearchTerms, Value = PPR.ApplicationPage_TargetFrameworksProperty_SearchTerms },
new() { Name = PropertyMetadata.DependsOn, Value = "Application::TargetMultipleFrameworks" }
}
};
StringProperty installOtherFrameworksProperty = new()
{
Name = "InstallOtherFrameworks",
DisplayName = PPR.ApplicationPage_InstallOtherFrameworksProperty_DisplayName,
Category = GeneralCategoryName,
DataSource = new()
{
PersistedName = "InstallOtherFrameworks",
Persistence = "ProjectFileWithInterception",
HasConfigurationCondition = false
},
ValueEditors =
{
new()
{
// TODO: EditorType could come from a constant
EditorType = "LinkAction",
Metadata =
{
new() { Name = "Action", Value = "URL" },
new() { Name = "URL", Value = "http://go.microsoft.com/fwlink/?LinkID=287120" }
}
}
}
};
DynamicEnumProperty targetPlatformIdentifierProperty = new()
{
Name = "TargetPlatformIdentifier",
DisplayName = PPR.ApplicationPage_TargetPlatformIdentifierProperty_DisplayName,
Description = PPR.ApplicationPage_TargetPlatformIdentifierProperty_Description,
Category = GeneralCategoryName,
EnumProvider = "SdkSupportedTargetPlatformIdentifierEnumProvider",
HelpUrl = "https://go.microsoft.com/fwlink/?linkid=2184943",
DataSource = new()
{
Persistence = "ProjectFileWithInterception",
HasConfigurationCondition = false
},
Metadata = new()
{
new() { Name = PropertyMetadata.SearchTerms, Value = PPR.ApplicationPage_TargetPlatformIdentifierProperty_SearchTerms },
new()
{
Name = PropertyMetadata.VisibilityCondition,
Value = @"
(and
(has-net-core-app-version-or-greater ""5.0"")
(not (has-evaluated-value ""Application"" ""TargetMultipleFrameworks"" true)))
"
}
}
};
DynamicEnumProperty targetPlatformVersionProperty = new()
{
Name = "TargetPlatformVersion",
DisplayName = PPR.ApplicationPage_TargetPlatformVersionProperty_DisplayName,
Description = PPR.ApplicationPage_TargetPlatformVersionProperty_Description,
Category = GeneralCategoryName,
EnumProvider = "SdkSupportedTargetPlatformVersionEnumProvider",
HelpUrl = "https://go.microsoft.com/fwlink/?linkid=2185153",
DataSource = new()
{
Persistence = "ProjectFileWithInterception",
HasConfigurationCondition = false
},
Metadata = new()
{
new()
{
Name = PropertyMetadata.VisibilityCondition,
Value =
@"
(and
(has-net-core-app-version-or-greater ""5.0"")
(and
(ne (unevaluated ""Application"" ""TargetPlatformIdentifier"") """")
(not (has-evaluated-value ""Application"" ""TargetMultipleFrameworks"" true))))
"
},
new() { Name = PropertyMetadata.SearchTerms, Value = PPR.ApplicationPage_TargetPlatformVersionProperty_SearchTerms },
new() { Name = PropertyMetadata.DependsOn, Value = "Application::TargetPlatformIdentifier" }
}
};
rule.Properties = new()
{
outputTypeProperty,
targetMultipleFrameworksProperty,
interceptedTargetFrameworkProperty,
targetFrameworksProperty,
installOtherFrameworksProperty,
targetPlatformIdentifierProperty,
targetPlatformVersionProperty,
};
rule.EndInit();
List<Rule> rules = new();
rules.Add(rule);
return rules;
}
private static Category CreateCategory(string name, string displayName, string description)
{
Category category = new();
category.BeginInit();
category.Name = name;
category.DisplayName = displayName;
category.Description = description;
category.EndInit();
return category;
}
public IReadOnlyCollection<Rule> GetRules() => _rules.Value;
}
}