-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor migrate-2017 to reduce code duplication * Split large files into multiple small ones * Move Service item filtering to separate transformation * Service is an item, not a property * Remove duplicates from input paths * Update MSBuild.Sdk.Extras versions for both .NET Core 2.x & 3.x * Update & fix tests for ServiceFilterTransformation
- Loading branch information
1 parent
ff1c66c
commit 734f05f
Showing
65 changed files
with
1,290 additions
and
738 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
Project2015To2017.Core/Transforms/ServiceFilterTransformation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Xml.Linq; | ||
using Project2015To2017.Definition; | ||
|
||
namespace Project2015To2017.Transforms | ||
{ | ||
public sealed class ServiceFilterTransformation : ITransformation | ||
{ | ||
private static readonly string[] KnownTestFrameworkIds = | ||
{ | ||
"Microsoft.NET.Test.Sdk", | ||
"xUnit.Core", | ||
"xUnit", | ||
"NUnit", | ||
}; | ||
|
||
private static readonly Version Vs15TestServiceFixVersion = new Version(15, 7); | ||
|
||
private readonly Version targetVisualStudioVersion; | ||
|
||
public ServiceFilterTransformation(Version targetVisualStudioVersion) | ||
{ | ||
this.targetVisualStudioVersion = targetVisualStudioVersion ?? throw new ArgumentNullException(nameof(targetVisualStudioVersion)); | ||
} | ||
|
||
public void Transform(Project definition) | ||
{ | ||
var removeQueue = definition.ItemGroups.ElementsAnyNamespace("Service").Where(IncludeMatchesSpecificGuid).ToArray(); | ||
|
||
foreach (var element in removeQueue) | ||
{ | ||
element.Remove(); | ||
} | ||
|
||
bool IncludeMatchesSpecificGuid(XElement child) | ||
{ | ||
if (string.Equals(child.Attribute("Include")?.Value, "{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}", | ||
StringComparison.InvariantCultureIgnoreCase)) | ||
{ | ||
// Fix is included with VS15.7 and above, but we might target VS15.0 | ||
// All known test providers also have a fix included | ||
return targetVisualStudioVersion >= Vs15TestServiceFixVersion || definition.PackageReferences.Any(IsKnownTestProvider); | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
|
||
private static bool IsKnownTestProvider(PackageReference x) | ||
{ | ||
// In theory, we should be checking versions of these test frameworks | ||
// to see, if they have the fix included. | ||
|
||
return KnownTestFrameworkIds.Contains(x.Id); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.