From 6d8bb7e4c4b51bd609650b17b235f5d9ab0994fb Mon Sep 17 00:00:00 2001
From: Glenn <5834289+glennawatson@users.noreply.github.com>
Date: Fri, 10 Jul 2020 18:49:09 +1000
Subject: [PATCH] Fix: change wpf/winforms (#146)
---
azure-pipelines.yml | 2 -
build.config | 2 +-
.../Extractors/NuGetExtractor.cs | 2 +-
.../NetCoreExtractorBase.cs | 64 +++++++++++++++++++
.../Extractors/PlatformExtractors/WPF.cs | 27 +++-----
.../Extractors/PlatformExtractors/Winforms.cs | 22 ++-----
version.json | 2 +-
7 files changed, 84 insertions(+), 37 deletions(-)
create mode 100644 src/Pharmacist.Core/Extractors/PlatformExtractors/NetCoreExtractorBase.cs
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index a67a9a9..cede92f 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -1,12 +1,10 @@
trigger:
-- master
- main
- latest
- rel/*
- preview/*
pr:
-- master
- main
- latest
- rel/*
diff --git a/build.config b/build.config
index 7d81123..3efaeaf 100644
--- a/build.config
+++ b/build.config
@@ -1 +1 @@
-CAKE_VERSION=0.38.1
+CAKE_VERSION=0.38.4
\ No newline at end of file
diff --git a/src/Pharmacist.Core/Extractors/NuGetExtractor.cs b/src/Pharmacist.Core/Extractors/NuGetExtractor.cs
index 5c2e881..ee05a25 100644
--- a/src/Pharmacist.Core/Extractors/NuGetExtractor.cs
+++ b/src/Pharmacist.Core/Extractors/NuGetExtractor.cs
@@ -21,7 +21,7 @@ namespace Pharmacist.Core.Extractors
public class NuGetExtractor : IExtractor
{
///
- public InputAssembliesGroup? Input { get; private set; }
+ public InputAssembliesGroup? Input { get; protected set; }
///
/// Extracts the data using the specified target framework.
diff --git a/src/Pharmacist.Core/Extractors/PlatformExtractors/NetCoreExtractorBase.cs b/src/Pharmacist.Core/Extractors/PlatformExtractors/NetCoreExtractorBase.cs
new file mode 100644
index 0000000..5d92bd2
--- /dev/null
+++ b/src/Pharmacist.Core/Extractors/PlatformExtractors/NetCoreExtractorBase.cs
@@ -0,0 +1,64 @@
+// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved.
+// 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 file in the project root for full license information.
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using NuGet.Frameworks;
+using NuGet.LibraryModel;
+using NuGet.Versioning;
+using Pharmacist.Core.Groups;
+using Pharmacist.Core.NuGet;
+
+namespace Pharmacist.Core.Extractors.PlatformExtractors
+{
+ ///
+ /// WPF platform assemblies and events.
+ ///
+ internal abstract class NetCoreExtractorBase : NuGetExtractor, IPlatformExtractor
+ {
+ private static readonly IReadOnlyList _frameworks = "netcoreapp3.1".ToFrameworks();
+ private static readonly LibraryRange _windowsDesktopReference = new LibraryRange("Microsoft.WindowsDesktop.App.Ref", VersionRange.Parse("3.*"), LibraryDependencyTarget.Package);
+
+ private readonly string? _filePath;
+
+ public NetCoreExtractorBase(string? filePath)
+ {
+ _filePath = filePath ?? Path.GetTempPath();
+ }
+
+ ///
+ public NuGetFramework Framework { get; } = _frameworks[0];
+
+ ///
+ public abstract AutoPlatform Platform { get; }
+
+ ///
+ /// Gets the wanted file names.
+ ///
+ protected abstract HashSet WantedFileNames { get; }
+
+ ///
+ public async Task Extract(string referenceAssembliesLocation)
+ {
+ await Extract(_frameworks, new[] { _windowsDesktopReference }, _filePath).ConfigureAwait(false);
+
+ if (Input == null)
+ {
+ return;
+ }
+
+ var fileMetadataEnumerable = Input.IncludeGroup.GetAllFileNames().Where(file => WantedFileNames.Contains(Path.GetFileName(file), StringComparer.InvariantCultureIgnoreCase));
+
+ var newInput = new InputAssembliesGroup();
+ newInput.IncludeGroup.AddFiles(fileMetadataEnumerable);
+ newInput.SupportGroup.AddFiles(Input.IncludeGroup.GetAllFileNames());
+ newInput.SupportGroup.AddFiles(Input.SupportGroup.GetAllFileNames());
+ Input = newInput;
+ }
+ }
+}
diff --git a/src/Pharmacist.Core/Extractors/PlatformExtractors/WPF.cs b/src/Pharmacist.Core/Extractors/PlatformExtractors/WPF.cs
index e51c900..28f19ad 100644
--- a/src/Pharmacist.Core/Extractors/PlatformExtractors/WPF.cs
+++ b/src/Pharmacist.Core/Extractors/PlatformExtractors/WPF.cs
@@ -4,38 +4,31 @@
// See the LICENSE file in the project root for full license information.
using System;
-using System.IO;
-using System.Linq;
-
-using Pharmacist.Core.Groups;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using NuGet.Frameworks;
namespace Pharmacist.Core.Extractors.PlatformExtractors
{
///
/// WPF platform assemblies and events.
///
- internal class WPF : NetFrameworkBase
+ internal class WPF : NetCoreExtractorBase
{
- private static readonly string[] WantedFileNames =
- {
- "WindowsBase.dll",
- "PresentationCore.dll",
- "PresentationFramework.dll"
- };
-
public WPF(string? filePath)
: base(filePath)
{
}
///
- public override AutoPlatform Platform { get; } = AutoPlatform.WPF;
+ public override AutoPlatform Platform => AutoPlatform.WPF;
///
- protected override void SetFiles(InputAssembliesGroup folderGroups)
+ protected override HashSet WantedFileNames { get; } = new HashSet(StringComparer.CurrentCultureIgnoreCase)
{
- var fileMetadataEnumerable = folderGroups.IncludeGroup.GetAllFileNames().Where(file => WantedFileNames.Contains(Path.GetFileName(file), StringComparer.InvariantCultureIgnoreCase));
- Input.IncludeGroup.AddFiles(fileMetadataEnumerable);
- }
+ "WindowsBase.dll",
+ "PresentationCore.dll",
+ "PresentationFramework.dll"
+ };
}
}
diff --git a/src/Pharmacist.Core/Extractors/PlatformExtractors/Winforms.cs b/src/Pharmacist.Core/Extractors/PlatformExtractors/Winforms.cs
index f555709..53cf383 100644
--- a/src/Pharmacist.Core/Extractors/PlatformExtractors/Winforms.cs
+++ b/src/Pharmacist.Core/Extractors/PlatformExtractors/Winforms.cs
@@ -4,24 +4,15 @@
// See the LICENSE file in the project root for full license information.
using System;
-using System.IO;
-using System.Linq;
-using Pharmacist.Core.Groups;
+using System.Collections.Generic;
namespace Pharmacist.Core.Extractors.PlatformExtractors
{
///
/// Win Forms platform assemblies and events.
///
- internal class Winforms : NetFrameworkBase
+ internal class Winforms : NetCoreExtractorBase
{
- private static readonly string[] WantedFileNames =
- {
- "System.DirectoryServices.dll",
- "System.Windows.Forms.dll",
- "System.Drawing.dll",
- };
-
public Winforms(string? filePath)
: base(filePath)
{
@@ -31,10 +22,11 @@ public Winforms(string? filePath)
public override AutoPlatform Platform => AutoPlatform.Winforms;
///
- protected override void SetFiles(InputAssembliesGroup folderGroups)
+ protected override HashSet WantedFileNames { get; } = new HashSet(StringComparer.CurrentCultureIgnoreCase)
{
- var fileMetadataEnumerable = folderGroups.IncludeGroup.GetAllFileNames().Where(file => WantedFileNames.Contains(Path.GetFileName(file), StringComparer.InvariantCultureIgnoreCase));
- Input.IncludeGroup.AddFiles(fileMetadataEnumerable);
- }
+ "System.DirectoryServices.dll",
+ "System.Windows.Forms.dll",
+ "System.Drawing.dll",
+ };
}
}
diff --git a/version.json b/version.json
index 23e7d07..4cf4797 100644
--- a/version.json
+++ b/version.json
@@ -1,5 +1,5 @@
{
- "version": "1.5",
+ "version": "1.6",
"publicReleaseRefSpec": [
"^refs/heads/main$", // we release out of master
"^refs/heads/rel/\\d+\\.\\d+\\.\\d+" // we also release branches starting with rel/N.N.N