Skip to content

Commit be9708a

Browse files
authored
dotnet-svcutil: refine TFX resolution and the referenced WCF versions, and update test baselines. (#5653)
* dotnet-svcutil: refine TFX resolution and the addition of WCF reference versions, and update test baselines. * Add wcf reference v4.10.* for targets lower than net8.0, for net8.0 and 9.0 add reference to 3 common 8.* packages. * Add warning for end-of-life framework targets * Update: address feedback.
1 parent ed1bd7a commit be9708a

File tree

76 files changed

+370
-369
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+370
-369
lines changed

src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6+
using System.Collections;
67
using System.Collections.Generic;
78
using System.Diagnostics;
89
using System.Globalization;
@@ -667,6 +668,18 @@ private async Task ProcessNamespaceMappingsOptionAsync(CancellationToken cancell
667668

668669
private async Task ProcessTargetFrameworkOptionAsync(CancellationToken cancellationToken)
669670
{
671+
if(this.Project != null)
672+
{
673+
this.Project.EndOfLifeTargetFrameworks?.ToList().ForEach(tfx => this.AddWarning(string.Format(CultureInfo.CurrentCulture, SR.WrnOutOfSupportTargetFrameworkFormat, tfx)));
674+
}
675+
else
676+
{
677+
if (TargetFrameworkHelper.IsEndofLifeFramework(this.TargetFramework?.FullName))
678+
{
679+
this.AddWarning(string.Format(CultureInfo.CurrentCulture, SR.WrnOutOfSupportTargetFrameworkFormat, this.TargetFramework.FullName));
680+
}
681+
}
682+
670683
if (this.TargetFramework == null)
671684
{
672685
var targetFrameworkMoniker = string.Empty;

src/dotnet-svcutil/lib/src/SR.resx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,4 +625,7 @@ Your credentials will be sent to the server in clear text.</value>
625625
<data name="WrnTargetFrameworkNotSupported_NetNamedPipe" xml:space="preserve">
626626
<value>NetNamedPipe is not supported on current .net target framework.</value>
627627
</data>
628-
</root>
628+
<data name="WrnOutOfSupportTargetFrameworkFormat" xml:space="preserve">
629+
<value>The target framework '{0}' is out of support and will not receive security updates in the future.</value>
630+
</data>
631+
</root>

src/dotnet-svcutil/lib/src/Shared/FrameworkInfo.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ internal class FrameworkInfo
1414
public const string Netstandard = "netstandard";
1515
public const string Netcoreapp = "netcoreapp";
1616
public const string Netfx = "net";
17+
public const string Netframework = "netframework";
1718
public const string Netversion = "version";
1819

1920
private FrameworkInfo()
@@ -24,7 +25,6 @@ private FrameworkInfo()
2425
public string Name { get; private set; }
2526
public Version Version { get; private set; }
2627
public bool IsDnx { get; private set; }
27-
public bool IsKnownDnx { get; private set; }
2828

2929
public static FrameworkInfo Parse(string fullFrameworkName)
3030
{
@@ -40,6 +40,7 @@ public static FrameworkInfo Parse(string fullFrameworkName)
4040
// framework spec form: 'net5.0'
4141
// framework spec form: '.NETCoreApp,Version=v6.0'
4242
// framework spec form: '.NETFramework,Version=v4.8'
43+
// framework spec form: '.NETStandard,Version=v2.0'
4344
// framework spec form: 'net7.0-windows10.0.19041.0', 'net7.0-windows'
4445
for (int i = 0; i < fullFrameworkName.Length; i++)
4546
{
@@ -76,16 +77,24 @@ public static FrameworkInfo Parse(string fullFrameworkName)
7677

7778
if (name.ToLower().Contains(Netversion))
7879
{
79-
//netcoreapp3.1 and lower
80-
if (version.Major < 4)
80+
//TFMoniker form ".NETStandard,Version=v2.0" resolves to framework name "netstandard."
81+
if (name.ToLower().Contains(Netstandard))
8182
{
82-
name = Netcoreapp;
83+
name = Netstandard;
8384
}
84-
else
85+
//TFMoniker form ".NETFramework,Version=v4.8" resolves to framework name "net"
86+
//TFMoniker form ".NETCoreApp,Version=v6.0" resolves to framework name "net"
87+
else if (name.ToLower().Contains(Netframework) || version.Major >= 5)
8588
{
8689
name = Netfx;
8790
}
8891

92+
//TFMoniker form ".NETCoreApp,Version=v3.1" resolves to framework name "netcoreapp"
93+
else
94+
{
95+
name = Netcoreapp;
96+
}
97+
8998
fullFrameworkName = string.Concat(name, version.ToString());
9099
}
91100

@@ -100,9 +109,6 @@ public static FrameworkInfo Parse(string fullFrameworkName)
100109
fxInfo.Name = name;
101110
fxInfo.Version = version;
102111
fxInfo.IsDnx = name == Netstandard || name == Netcoreapp || version.Major >= 5;
103-
fxInfo.IsKnownDnx = fxInfo.IsDnx &&
104-
(TargetFrameworkHelper.NetStandardToNetCoreVersionMap.Keys.Any((netstdVersion) => netstdVersion == version) ||
105-
TargetFrameworkHelper.NetStandardToNetCoreVersionMap.Values.Any((netcoreVersion) => netcoreVersion == version));
106112

107113
return fxInfo;
108114
}

src/dotnet-svcutil/lib/src/Shared/MSBuildProj.cs

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public string TargetFramework
4343
}
4444

4545
private List<string> _targetFrameworks = new List<string>();
46+
private List<string> _endOfLifeTargetFrameworks = new List<string>();
4647
public IEnumerable<string> TargetFrameworks { get { return _targetFrameworks; } }
48+
internal IEnumerable<string> EndOfLifeTargetFrameworks { get { return _endOfLifeTargetFrameworks; } }
4749

4850
private string _runtimeIdentifier;
4951
public string RuntimeIdentifier
@@ -133,17 +135,6 @@ private XElement PacakgeReferenceGroup
133135
{
134136
_packageReferenceGroup = refItems.FirstOrDefault().Parent;
135137
}
136-
137-
FrameworkInfo netfxInfo = null;
138-
FrameworkInfo dnxInfo = null;
139-
if (this.TargetFrameworks.Count() > 1 && this.TargetFrameworks.Any(t => TargetFrameworkHelper.IsSupportedFramework(t, out netfxInfo) && !netfxInfo.IsDnx))
140-
{
141-
var tfx = this.TargetFrameworks.FirstOrDefault(t => TargetFrameworkHelper.IsSupportedFramework(t, out dnxInfo) && dnxInfo.IsDnx);
142-
if (!string.IsNullOrEmpty(tfx) && dnxInfo.Version.Major >= 6)
143-
{
144-
_packageReferenceGroup.Add(new XAttribute("Condition", $"'$(TargetFramework)' != '{netfxInfo.FullName}'"));
145-
}
146-
}
147138
}
148139

149140
return _packageReferenceGroup;
@@ -242,9 +233,9 @@ public static async Task<MSBuildProj> ParseAsync(string projectText, string proj
242233
}
243234
else
244235
{
245-
msbuildProj._targetFramework = string.Concat("net", TargetFrameworkHelper.NetCoreVersionReferenceTable.LastOrDefault().Key.ToString());
236+
msbuildProj._targetFramework = string.Concat("net", TargetFrameworkHelper.s_currentSupportedVersions.First());
246237
}
247-
238+
248239
msbuildProj._targetFrameworks.Add(msbuildProj._targetFramework);
249240
}
250241

@@ -369,7 +360,13 @@ public static async Task<MSBuildProj> ParseAsync(string projectText, string proj
369360

370361
var sdkVersion = await ProjectPropertyResolver.GetSdkVersionAsync(msbuildProj.DirectoryPath, logger, cancellationToken).ConfigureAwait(false);
371362
msbuildProj.SdkVersion = sdkVersion ?? string.Empty;
372-
363+
foreach (var tfx in msbuildProj._targetFrameworks)
364+
{
365+
if(TargetFrameworkHelper.IsEndofLifeFramework(tfx))
366+
{
367+
msbuildProj._endOfLifeTargetFrameworks.Add(tfx);
368+
}
369+
}
373370
return msbuildProj;
374371
}
375372
}
@@ -541,21 +538,7 @@ public bool AddDependency(ProjectDependency dependency, bool copyInternalAssets
541538
this.ProjectReferceGroup.Add(new XElement("ProjectReference", new XAttribute("Include", dependency.FullPath)));
542539
break;
543540
case ProjectDependencyType.Binary:
544-
FrameworkInfo netfxInfo = null;
545-
FrameworkInfo dnxInfo = null;
546-
string dnxStr = this.TargetFrameworks.FirstOrDefault(t => TargetFrameworkHelper.IsSupportedFramework(t, out dnxInfo) && dnxInfo.IsDnx);
547-
if (this.TargetFrameworks.Count() > 1 && dependency.Name.Equals(TargetFrameworkHelper.FullFrameworkReferences.FirstOrDefault().Name)
548-
&& !string.IsNullOrWhiteSpace(dnxStr) && dnxInfo.Version.Major >= 6)
549-
{
550-
if (this.TargetFrameworks.Any(t => TargetFrameworkHelper.IsSupportedFramework(t, out netfxInfo) && !netfxInfo.IsDnx))
551-
{
552-
this.ReferenceGroup.Add(new XElement("Reference", new XAttribute("Condition", $"'$(TargetFramework)' == '{netfxInfo.FullName}'"), new XAttribute("Include", dependency.AssemblyName), new XElement("HintPath", dependency.FullPath)));
553-
}
554-
}
555-
else
556-
{
557-
this.ReferenceGroup.Add(new XElement("Reference", new XAttribute("Include", dependency.AssemblyName), new XElement("HintPath", dependency.FullPath)));
558-
}
541+
this.ReferenceGroup.Add(new XElement("Reference", new XAttribute("Include", dependency.AssemblyName), new XElement("HintPath", dependency.FullPath)));
559542
break;
560543
case ProjectDependencyType.Package:
561544
this.PacakgeReferenceGroup.Add(new XElement("PackageReference", new XAttribute("Include", dependency.Name), new XAttribute("Version", dependency.Version)));

0 commit comments

Comments
 (0)