-
Notifications
You must be signed in to change notification settings - Fork 696
/
DefaultFrameworkMappings.cs
664 lines (569 loc) · 34.3 KB
/
DefaultFrameworkMappings.cs
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
namespace NuGet.Frameworks
{
public sealed class DefaultFrameworkMappings : IFrameworkMappings
{
private static Lazy<KeyValuePair<string, string>[]> IdentifierSynonymsLazy = new Lazy<KeyValuePair<string, string>[]>(() =>
{
return new[]{
// .NET
new KeyValuePair<string, string>("NETFramework", FrameworkConstants.FrameworkIdentifiers.Net),
new KeyValuePair<string, string>(".NET", FrameworkConstants.FrameworkIdentifiers.Net),
// .NET Core
new KeyValuePair<string, string>("NETCore", FrameworkConstants.FrameworkIdentifiers.NetCore),
// Portable
new KeyValuePair<string, string>("NETPortable", FrameworkConstants.FrameworkIdentifiers.Portable),
// ASP
new KeyValuePair<string, string>("asp.net", FrameworkConstants.FrameworkIdentifiers.AspNet),
new KeyValuePair<string, string>("asp.netcore", FrameworkConstants.FrameworkIdentifiers.AspNetCore),
// Mono/Xamarin
new KeyValuePair<string, string>("Xamarin.PlayStationThree", FrameworkConstants.FrameworkIdentifiers.XamarinPlayStation3),
new KeyValuePair<string, string>("XamarinPlayStationThree", FrameworkConstants.FrameworkIdentifiers.XamarinPlayStation3),
new KeyValuePair<string, string>("Xamarin.PlayStationFour", FrameworkConstants.FrameworkIdentifiers.XamarinPlayStation4),
new KeyValuePair<string, string>("XamarinPlayStationFour", FrameworkConstants.FrameworkIdentifiers.XamarinPlayStation4),
new KeyValuePair<string, string>("XamarinPlayStationVita", FrameworkConstants.FrameworkIdentifiers.XamarinPlayStationVita),
};
});
public IEnumerable<KeyValuePair<string, string>> IdentifierSynonyms
{
get
{
return IdentifierSynonymsLazy.Value;
}
}
private static readonly Lazy<KeyValuePair<string, string>[]> IdentifierShortNamesLazy = new Lazy<KeyValuePair<string, string>[]>(() =>
{
return new[]
{
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.NetCoreApp, "netcoreapp"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.NetStandardApp, "netstandardapp"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.NetStandard, "netstandard"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.NetPlatform, "dotnet"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.Net, "net"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.NetMicro, "netmf"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.Silverlight, "sl"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.Portable, "portable"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.WindowsPhone, "wp"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.WindowsPhoneApp, "wpa"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.Windows, "win"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.AspNet, "aspnet"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.AspNetCore, "aspnetcore"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.Native, "native"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.MonoAndroid, "monoandroid"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.MonoTouch, "monotouch"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.MonoMac, "monomac"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinIOs, "xamarinios"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinMac, "xamarinmac"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinPlayStation3, "xamarinpsthree"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinPlayStation4, "xamarinpsfour"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinPlayStationVita, "xamarinpsvita"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinWatchOS, "xamarinwatchos"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinTVOS, "xamarintvos"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinXbox360, "xamarinxboxthreesixty"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinXboxOne, "xamarinxboxone"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.Dnx, "dnx"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.DnxCore, "dnxcore"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.NetCore, "netcore"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.WinRT, "winrt"), // legacy
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.UAP, "uap"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.Tizen, "tizen"),
new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.NanoFramework, "netnano"),
};
});
public IEnumerable<KeyValuePair<string, string>> IdentifierShortNames
{
get
{
return IdentifierShortNamesLazy.Value;
}
}
private static readonly Lazy<FrameworkSpecificMapping[]> ProfileShortNamesLazy = new Lazy<FrameworkSpecificMapping[]>(() =>
{
return new[]
{
new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.Net, "Client", "Client"),
new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.Net, "CF", "CompactFramework"),
new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.Net, "Full", string.Empty),
new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.Silverlight, "WP", "WindowsPhone"),
new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.Silverlight, "WP71", "WindowsPhone71"),
};
});
public IEnumerable<FrameworkSpecificMapping> ProfileShortNames
{
get
{
return ProfileShortNamesLazy.Value;
}
}
private static readonly Lazy<KeyValuePair<NuGetFramework, NuGetFramework>[]> EquivalentFrameworksLazy = new Lazy<KeyValuePair<NuGetFramework, NuGetFramework>[]>(() =>
{
return new[]
{
// UAP 0.0 <-> UAP 10.0
new KeyValuePair<NuGetFramework, NuGetFramework>(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.UAP, FrameworkConstants.EmptyVersion),
FrameworkConstants.CommonFrameworks.UAP10),
// win <-> win8
new KeyValuePair<NuGetFramework, NuGetFramework>(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.Windows, FrameworkConstants.EmptyVersion),
FrameworkConstants.CommonFrameworks.Win8),
// win8 <-> netcore45
new KeyValuePair<NuGetFramework, NuGetFramework>(
FrameworkConstants.CommonFrameworks.Win8,
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.NetCore, new Version(4, 5, 0, 0))),
// netcore45 <-> winrt45
new KeyValuePair<NuGetFramework, NuGetFramework>(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.NetCore, new Version(4, 5, 0, 0)),
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.WinRT, new Version(4, 5, 0, 0))),
// netcore <-> netcore45
new KeyValuePair<NuGetFramework, NuGetFramework>(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.NetCore, FrameworkConstants.EmptyVersion),
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.NetCore, new Version(4, 5, 0, 0))),
// winrt <-> winrt45
new KeyValuePair<NuGetFramework, NuGetFramework>(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.WinRT, FrameworkConstants.EmptyVersion),
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.WinRT, new Version(4, 5, 0, 0))),
// win81 <-> netcore451
new KeyValuePair<NuGetFramework, NuGetFramework>(
FrameworkConstants.CommonFrameworks.Win81,
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.NetCore, new Version(4, 5, 1, 0))),
// wp <-> wp7
new KeyValuePair<NuGetFramework, NuGetFramework>(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.WindowsPhone, FrameworkConstants.EmptyVersion),
FrameworkConstants.CommonFrameworks.WP7),
// wp7 <-> f:sl3-wp
new KeyValuePair<NuGetFramework, NuGetFramework>(
FrameworkConstants.CommonFrameworks.WP7,
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.Silverlight, new Version(3, 0, 0, 0), "WindowsPhone")),
// wp71 <-> f:sl4-wp71
new KeyValuePair<NuGetFramework, NuGetFramework>(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.WindowsPhone, new Version(7, 1, 0, 0)),
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.Silverlight, new Version(4, 0, 0, 0), "WindowsPhone71")),
// wp8 <-> f:sl8-wp
new KeyValuePair<NuGetFramework, NuGetFramework>(
FrameworkConstants.CommonFrameworks.WP8,
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.Silverlight, new Version(8, 0, 0, 0), "WindowsPhone")),
// wp81 <-> f:sl81-wp
new KeyValuePair<NuGetFramework, NuGetFramework>(
FrameworkConstants.CommonFrameworks.WP81,
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.Silverlight, new Version(8, 1, 0, 0), "WindowsPhone")),
// wpa <-> wpa81
new KeyValuePair<NuGetFramework, NuGetFramework>(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.WindowsPhoneApp, FrameworkConstants.EmptyVersion),
FrameworkConstants.CommonFrameworks.WPA81),
// tizen <-> tizen3
new KeyValuePair<NuGetFramework, NuGetFramework>(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.Tizen, FrameworkConstants.EmptyVersion),
FrameworkConstants.CommonFrameworks.Tizen3),
// dnx <-> dnx45
new KeyValuePair<NuGetFramework, NuGetFramework>(
FrameworkConstants.CommonFrameworks.Dnx,
FrameworkConstants.CommonFrameworks.Dnx45),
// dnxcore <-> dnxcore50
new KeyValuePair<NuGetFramework, NuGetFramework>(
FrameworkConstants.CommonFrameworks.DnxCore,
FrameworkConstants.CommonFrameworks.DnxCore50),
// dotnet <-> dotnet50
new KeyValuePair<NuGetFramework, NuGetFramework>(
FrameworkConstants.CommonFrameworks.DotNet,
FrameworkConstants.CommonFrameworks.DotNet50),
// TODO: remove these rules post-RC
// aspnet <-> aspnet50
new KeyValuePair<NuGetFramework, NuGetFramework>(
FrameworkConstants.CommonFrameworks.AspNet,
FrameworkConstants.CommonFrameworks.AspNet50),
// aspnetcore <-> aspnetcore50
new KeyValuePair<NuGetFramework, NuGetFramework>(
FrameworkConstants.CommonFrameworks.AspNetCore,
FrameworkConstants.CommonFrameworks.AspNetCore50),
// dnx451 <-> aspnet50
new KeyValuePair<NuGetFramework, NuGetFramework>(
FrameworkConstants.CommonFrameworks.Dnx45,
FrameworkConstants.CommonFrameworks.AspNet50),
// dnxcore50 <-> aspnetcore50
new KeyValuePair<NuGetFramework, NuGetFramework>(
FrameworkConstants.CommonFrameworks.DnxCore50,
FrameworkConstants.CommonFrameworks.AspNetCore50),
};
});
public IEnumerable<KeyValuePair<NuGetFramework, NuGetFramework>> EquivalentFrameworks
{
get
{
return EquivalentFrameworksLazy.Value;
}
}
private static readonly Lazy<FrameworkSpecificMapping[]> EquivalentProfilesLazy = new Lazy<FrameworkSpecificMapping[]>(() =>
{
return new[]
{
// The client profile, for the purposes of NuGet, is the same as the full framework
new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.Net, "Client", string.Empty),
new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.Net, "Full", string.Empty),
new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.Silverlight, "WindowsPhone71", "WindowsPhone"),
new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.WindowsPhone, "WindowsPhone71", "WindowsPhone"),
};
});
public IEnumerable<FrameworkSpecificMapping> EquivalentProfiles
{
get
{
return EquivalentProfilesLazy.Value;
}
}
private static readonly Lazy<KeyValuePair<string, string>[]> SubSetFrameworksLazy = new Lazy<KeyValuePair<string, string>[]>(() =>
{
return new[]
{
// .NET is a subset of DNX
new KeyValuePair<string, string>(
FrameworkConstants.FrameworkIdentifiers.Net,
FrameworkConstants.FrameworkIdentifiers.Dnx),
// NetPlatform is a subset of DNXCore
new KeyValuePair<string, string>(
FrameworkConstants.FrameworkIdentifiers.NetPlatform,
FrameworkConstants.FrameworkIdentifiers.DnxCore),
// NetStandard is a subset of NetStandardApp
new KeyValuePair<string, string>(
FrameworkConstants.FrameworkIdentifiers.NetStandard,
FrameworkConstants.FrameworkIdentifiers.NetStandardApp)
};
});
public IEnumerable<KeyValuePair<string, string>> SubSetFrameworks
{
get
{
return SubSetFrameworksLazy.Value;
}
}
private static readonly Lazy<OneWayCompatibilityMappingEntry[]> CompatibilityMappingsLazy = new Lazy<OneWayCompatibilityMappingEntry[]>(() =>
{
return new[]
{
// UAP supports Win81
new OneWayCompatibilityMappingEntry(new FrameworkRange(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.UAP, FrameworkConstants.EmptyVersion),
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.UAP, FrameworkConstants.MaxVersion)),
new FrameworkRange(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.Windows, FrameworkConstants.EmptyVersion),
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.Windows, new Version(8, 1, 0, 0)))),
// UAP supports WPA81
new OneWayCompatibilityMappingEntry(new FrameworkRange(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.UAP, FrameworkConstants.EmptyVersion),
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.UAP, FrameworkConstants.MaxVersion)),
new FrameworkRange(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.WindowsPhoneApp, FrameworkConstants.EmptyVersion),
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.WindowsPhoneApp, new Version(8, 1, 0, 0)))),
// UAP supports NetCore50
new OneWayCompatibilityMappingEntry(new FrameworkRange(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.UAP, FrameworkConstants.EmptyVersion),
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.UAP, FrameworkConstants.MaxVersion)),
new FrameworkRange(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.NetCore, FrameworkConstants.Version5),
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.NetCore, FrameworkConstants.Version5))),
// Win projects support WinRT
new OneWayCompatibilityMappingEntry(new FrameworkRange(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.Windows, FrameworkConstants.EmptyVersion),
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.Windows, FrameworkConstants.MaxVersion)),
new FrameworkRange(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.WinRT, FrameworkConstants.EmptyVersion),
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.WinRT, new Version(4, 5, 0, 0)))),
// Tizen3 projects support NETStandard1.6
CreateStandardMapping(
FrameworkConstants.CommonFrameworks.Tizen3,
FrameworkConstants.CommonFrameworks.NetStandard16),
// Tizen4 projects support NETStandard2.0
CreateStandardMapping(
FrameworkConstants.CommonFrameworks.Tizen4,
FrameworkConstants.CommonFrameworks.NetStandard20),
// Tizen6 projects support NETStandard2.1
CreateStandardMapping(
FrameworkConstants.CommonFrameworks.Tizen6,
FrameworkConstants.CommonFrameworks.NetStandard21),
// UAP 10.0.15064.0 projects support NETStandard2.0
CreateStandardMapping(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.UAP, new Version(10, 0, 15064, 0)),
FrameworkConstants.CommonFrameworks.NetStandard20),
// NetCoreApp1.0 projects support NetStandard1.6
CreateStandardMapping(
FrameworkConstants.CommonFrameworks.NetCoreApp10,
FrameworkConstants.CommonFrameworks.NetStandard16),
// NetCoreApp1.1 projects support NetStandard1.7
CreateStandardMapping(
FrameworkConstants.CommonFrameworks.NetCoreApp11,
FrameworkConstants.CommonFrameworks.NetStandard17),
// NetCoreApp2.0 projects support NetStandard2.0
CreateStandardMapping(
FrameworkConstants.CommonFrameworks.NetCoreApp20,
FrameworkConstants.CommonFrameworks.NetStandard20),
// NetCoreApp3.0 projects support NetStandard2.1
CreateStandardMapping(
FrameworkConstants.CommonFrameworks.NetCoreApp30,
FrameworkConstants.CommonFrameworks.NetStandard21),
// net463 projects support NetStandard2.0
CreateStandardMapping(
FrameworkConstants.CommonFrameworks.Net463,
FrameworkConstants.CommonFrameworks.NetStandard20)
}
.Concat(new[]
{
// dnxcore50 -> dotnet5.6, netstandard1.5
CreateGenerationAndStandardMappingForAllVersions(
FrameworkConstants.FrameworkIdentifiers.DnxCore,
FrameworkConstants.CommonFrameworks.DotNet56,
FrameworkConstants.CommonFrameworks.NetStandard15),
// uap -> dotnet5.5, netstandard1.4
CreateGenerationAndStandardMappingForAllVersions(
FrameworkConstants.FrameworkIdentifiers.UAP,
FrameworkConstants.CommonFrameworks.DotNet55,
FrameworkConstants.CommonFrameworks.NetStandard14),
// netcore50 -> dotnet5.5, netstandard1.4
CreateGenerationAndStandardMapping(
FrameworkConstants.CommonFrameworks.NetCore50,
FrameworkConstants.CommonFrameworks.DotNet55,
FrameworkConstants.CommonFrameworks.NetStandard14),
// wpa81 -> dotnet5.3, netstandard1.2
CreateGenerationAndStandardMapping(
FrameworkConstants.CommonFrameworks.WPA81,
FrameworkConstants.CommonFrameworks.DotNet53,
FrameworkConstants.CommonFrameworks.NetStandard12),
// wp8, wp81 -> dotnet5.1, netstandard1.0
CreateGenerationAndStandardMapping(
FrameworkConstants.CommonFrameworks.WP8,
FrameworkConstants.CommonFrameworks.DotNet51,
FrameworkConstants.CommonFrameworks.NetStandard10),
// net45 -> dotnet5.2, netstandard1.1
CreateGenerationAndStandardMapping(
FrameworkConstants.CommonFrameworks.Net45,
FrameworkConstants.CommonFrameworks.DotNet52,
FrameworkConstants.CommonFrameworks.NetStandard11),
// net451 -> dotnet5.3, netstandard1.2
CreateGenerationAndStandardMapping(
FrameworkConstants.CommonFrameworks.Net451,
FrameworkConstants.CommonFrameworks.DotNet53,
FrameworkConstants.CommonFrameworks.NetStandard12),
// net46 -> dotnet5.4, netstandard1.3
CreateGenerationAndStandardMapping(
FrameworkConstants.CommonFrameworks.Net46,
FrameworkConstants.CommonFrameworks.DotNet54,
FrameworkConstants.CommonFrameworks.NetStandard13),
// net461 -> dotnet5.5, netstandard2.0
CreateGenerationAndStandardMapping(
FrameworkConstants.CommonFrameworks.Net461,
FrameworkConstants.CommonFrameworks.DotNet55,
FrameworkConstants.CommonFrameworks.NetStandard20),
// net462 -> dotnet5.6, netstandard2.0
CreateGenerationAndStandardMapping(
FrameworkConstants.CommonFrameworks.Net462,
FrameworkConstants.CommonFrameworks.DotNet56,
FrameworkConstants.CommonFrameworks.NetStandard20),
// netcore45 -> dotnet5.2, netstandard1.1
CreateGenerationAndStandardMapping(
FrameworkConstants.CommonFrameworks.NetCore45,
FrameworkConstants.CommonFrameworks.DotNet52,
FrameworkConstants.CommonFrameworks.NetStandard11),
// netcore451 -> dotnet5.3, netstandard1.2
CreateGenerationAndStandardMapping(
FrameworkConstants.CommonFrameworks.NetCore451,
FrameworkConstants.CommonFrameworks.DotNet53,
FrameworkConstants.CommonFrameworks.NetStandard12),
// xamarin frameworks
CreateGenerationAndStandardMappingForAllVersions(
FrameworkConstants.FrameworkIdentifiers.MonoAndroid,
FrameworkConstants.CommonFrameworks.DotNet56,
FrameworkConstants.CommonFrameworks.NetStandard21),
CreateGenerationAndStandardMappingForAllVersions(
FrameworkConstants.FrameworkIdentifiers.MonoMac,
FrameworkConstants.CommonFrameworks.DotNet56,
FrameworkConstants.CommonFrameworks.NetStandard21),
CreateGenerationAndStandardMappingForAllVersions(
FrameworkConstants.FrameworkIdentifiers.MonoTouch,
FrameworkConstants.CommonFrameworks.DotNet56,
FrameworkConstants.CommonFrameworks.NetStandard21),
CreateGenerationAndStandardMappingForAllVersions(
FrameworkConstants.FrameworkIdentifiers.XamarinIOs,
FrameworkConstants.CommonFrameworks.DotNet56,
FrameworkConstants.CommonFrameworks.NetStandard21),
CreateGenerationAndStandardMappingForAllVersions(
FrameworkConstants.FrameworkIdentifiers.XamarinMac,
FrameworkConstants.CommonFrameworks.DotNet56,
FrameworkConstants.CommonFrameworks.NetStandard21),
CreateGenerationAndStandardMappingForAllVersions(
FrameworkConstants.FrameworkIdentifiers.XamarinPlayStation3,
FrameworkConstants.CommonFrameworks.DotNet56,
FrameworkConstants.CommonFrameworks.NetStandard20),
CreateGenerationAndStandardMappingForAllVersions(
FrameworkConstants.FrameworkIdentifiers.XamarinPlayStation4,
FrameworkConstants.CommonFrameworks.DotNet56,
FrameworkConstants.CommonFrameworks.NetStandard20),
CreateGenerationAndStandardMappingForAllVersions(
FrameworkConstants.FrameworkIdentifiers.XamarinPlayStationVita,
FrameworkConstants.CommonFrameworks.DotNet56,
FrameworkConstants.CommonFrameworks.NetStandard20),
CreateGenerationAndStandardMappingForAllVersions(
FrameworkConstants.FrameworkIdentifiers.XamarinXbox360,
FrameworkConstants.CommonFrameworks.DotNet56,
FrameworkConstants.CommonFrameworks.NetStandard20),
CreateGenerationAndStandardMappingForAllVersions(
FrameworkConstants.FrameworkIdentifiers.XamarinXboxOne,
FrameworkConstants.CommonFrameworks.DotNet56,
FrameworkConstants.CommonFrameworks.NetStandard20),
CreateGenerationAndStandardMappingForAllVersions(
FrameworkConstants.FrameworkIdentifiers.XamarinTVOS,
FrameworkConstants.CommonFrameworks.DotNet56,
FrameworkConstants.CommonFrameworks.NetStandard21),
CreateGenerationAndStandardMappingForAllVersions(
FrameworkConstants.FrameworkIdentifiers.XamarinWatchOS,
FrameworkConstants.CommonFrameworks.DotNet56,
FrameworkConstants.CommonFrameworks.NetStandard21)
}.SelectMany(mappings => mappings))
.ToArray();
});
public IEnumerable<OneWayCompatibilityMappingEntry> CompatibilityMappings
{
get
{
return CompatibilityMappingsLazy.Value;
}
}
private static OneWayCompatibilityMappingEntry CreateGenerationMapping(
NuGetFramework framework,
NuGetFramework netPlatform)
{
return new OneWayCompatibilityMappingEntry(
new FrameworkRange(
framework,
new NuGetFramework(framework.Framework, FrameworkConstants.MaxVersion)),
new FrameworkRange(
FrameworkConstants.CommonFrameworks.DotNet,
netPlatform));
}
private static OneWayCompatibilityMappingEntry CreateStandardMapping(
NuGetFramework framework,
NuGetFramework netPlatform)
{
return new OneWayCompatibilityMappingEntry(
new FrameworkRange(
framework,
new NuGetFramework(framework.Framework, FrameworkConstants.MaxVersion)),
new FrameworkRange(
FrameworkConstants.CommonFrameworks.NetStandard10,
netPlatform));
}
private static IEnumerable<OneWayCompatibilityMappingEntry> CreateGenerationAndStandardMapping(
NuGetFramework framework,
NuGetFramework netPlatform,
NuGetFramework netStandard)
{
yield return CreateGenerationMapping(framework, netPlatform);
yield return CreateStandardMapping(framework, netStandard);
}
private static IEnumerable<OneWayCompatibilityMappingEntry> CreateGenerationAndStandardMappingForAllVersions(
string framework,
NuGetFramework netPlatform,
NuGetFramework netStandard)
{
var lowestFramework = new NuGetFramework(framework, FrameworkConstants.EmptyVersion);
return CreateGenerationAndStandardMapping(lowestFramework, netPlatform, netStandard);
}
private static readonly Lazy<string[]> NonPackageBasedFrameworkPrecedenceLazy = new Lazy<string[]>(() =>
{
return new[]
{
FrameworkConstants.FrameworkIdentifiers.Net,
FrameworkConstants.FrameworkIdentifiers.NetCore,
FrameworkConstants.FrameworkIdentifiers.Windows,
FrameworkConstants.FrameworkIdentifiers.WindowsPhoneApp
};
});
public IEnumerable<string> NonPackageBasedFrameworkPrecedence
{
get
{
return NonPackageBasedFrameworkPrecedenceLazy.Value;
}
}
private static readonly Lazy<string[]> PackageBasedFrameworkPrecedenceLazy = new Lazy<string[]>(() =>
{
return new[]
{
FrameworkConstants.FrameworkIdentifiers.NetCoreApp,
FrameworkConstants.FrameworkIdentifiers.NetStandardApp,
FrameworkConstants.FrameworkIdentifiers.NetStandard,
FrameworkConstants.FrameworkIdentifiers.NetPlatform
};
});
public IEnumerable<string> PackageBasedFrameworkPrecedence
{
get
{
return PackageBasedFrameworkPrecedenceLazy.Value;
}
}
private static readonly Lazy<string[]> EquivalentFrameworkPrecedenceLazy = new Lazy<string[]>(() =>
{
return new[]
{
FrameworkConstants.FrameworkIdentifiers.Windows,
FrameworkConstants.FrameworkIdentifiers.NetCore,
FrameworkConstants.FrameworkIdentifiers.WinRT,
FrameworkConstants.FrameworkIdentifiers.WindowsPhone,
FrameworkConstants.FrameworkIdentifiers.Silverlight,
FrameworkConstants.FrameworkIdentifiers.DnxCore,
FrameworkConstants.FrameworkIdentifiers.AspNetCore,
FrameworkConstants.FrameworkIdentifiers.Dnx,
FrameworkConstants.FrameworkIdentifiers.AspNet
};
});
public IEnumerable<string> EquivalentFrameworkPrecedence
{
get
{
return EquivalentFrameworkPrecedenceLazy.Value;
}
}
private static readonly Lazy<KeyValuePair<NuGetFramework, NuGetFramework>[]> ShortNameReplacementsLazy = new Lazy<KeyValuePair<NuGetFramework, NuGetFramework>[]>(() =>
{
return new[]
{
new KeyValuePair<NuGetFramework, NuGetFramework>(FrameworkConstants.CommonFrameworks.DotNet50, FrameworkConstants.CommonFrameworks.DotNet)
};
});
public IEnumerable<KeyValuePair<NuGetFramework, NuGetFramework>> ShortNameReplacements
{
get
{
return ShortNameReplacementsLazy.Value;
}
}
private static readonly Lazy<KeyValuePair<NuGetFramework, NuGetFramework>[]> FullNameReplacementsLazy = new Lazy<KeyValuePair<NuGetFramework, NuGetFramework>[]>(() =>
{
return new[]
{
new KeyValuePair<NuGetFramework, NuGetFramework>(FrameworkConstants.CommonFrameworks.DotNet, FrameworkConstants.CommonFrameworks.DotNet50)
};
});
public IEnumerable<KeyValuePair<NuGetFramework, NuGetFramework>> FullNameReplacements
{
get
{
return FullNameReplacementsLazy.Value;
}
}
private static readonly Lazy<IFrameworkMappings> InstanceLazy = new Lazy<IFrameworkMappings>(() => new DefaultFrameworkMappings());
/// <summary>
/// Singleton instance of the default framework mappings.
/// </summary>
public static IFrameworkMappings Instance
{
get
{
return InstanceLazy.Value;
}
}
}
}