Skip to content

Commit 6d8bb7e

Browse files
authored
Fix: change wpf/winforms (#146)
1 parent f4124d6 commit 6d8bb7e

File tree

7 files changed

+84
-37
lines changed

7 files changed

+84
-37
lines changed

azure-pipelines.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
trigger:
2-
- master
32
- main
43
- latest
54
- rel/*
65
- preview/*
76

87
pr:
9-
- master
108
- main
119
- latest
1210
- rel/*

build.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
CAKE_VERSION=0.38.1
1+
CAKE_VERSION=0.38.4

src/Pharmacist.Core/Extractors/NuGetExtractor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace Pharmacist.Core.Extractors
2121
public class NuGetExtractor : IExtractor
2222
{
2323
/// <inheritdoc />
24-
public InputAssembliesGroup? Input { get; private set; }
24+
public InputAssembliesGroup? Input { get; protected set; }
2525

2626
/// <summary>
2727
/// Extracts the data using the specified target framework.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved.
2+
// Licensed to the .NET Foundation under one or more agreements.
3+
// The .NET Foundation licenses this file to you under the MIT license.
4+
// See the LICENSE file in the project root for full license information.
5+
6+
using System;
7+
using System.Collections.Generic;
8+
using System.IO;
9+
using System.Linq;
10+
using System.Threading.Tasks;
11+
using NuGet.Frameworks;
12+
using NuGet.LibraryModel;
13+
using NuGet.Versioning;
14+
using Pharmacist.Core.Groups;
15+
using Pharmacist.Core.NuGet;
16+
17+
namespace Pharmacist.Core.Extractors.PlatformExtractors
18+
{
19+
/// <summary>
20+
/// WPF platform assemblies and events.
21+
/// </summary>
22+
internal abstract class NetCoreExtractorBase : NuGetExtractor, IPlatformExtractor
23+
{
24+
private static readonly IReadOnlyList<NuGetFramework> _frameworks = "netcoreapp3.1".ToFrameworks();
25+
private static readonly LibraryRange _windowsDesktopReference = new LibraryRange("Microsoft.WindowsDesktop.App.Ref", VersionRange.Parse("3.*"), LibraryDependencyTarget.Package);
26+
27+
private readonly string? _filePath;
28+
29+
public NetCoreExtractorBase(string? filePath)
30+
{
31+
_filePath = filePath ?? Path.GetTempPath();
32+
}
33+
34+
/// <inheritdoc />
35+
public NuGetFramework Framework { get; } = _frameworks[0];
36+
37+
/// <inheritdoc />
38+
public abstract AutoPlatform Platform { get; }
39+
40+
/// <summary>
41+
/// Gets the wanted file names.
42+
/// </summary>
43+
protected abstract HashSet<string> WantedFileNames { get; }
44+
45+
/// <inheritdoc />
46+
public async Task Extract(string referenceAssembliesLocation)
47+
{
48+
await Extract(_frameworks, new[] { _windowsDesktopReference }, _filePath).ConfigureAwait(false);
49+
50+
if (Input == null)
51+
{
52+
return;
53+
}
54+
55+
var fileMetadataEnumerable = Input.IncludeGroup.GetAllFileNames().Where(file => WantedFileNames.Contains(Path.GetFileName(file), StringComparer.InvariantCultureIgnoreCase));
56+
57+
var newInput = new InputAssembliesGroup();
58+
newInput.IncludeGroup.AddFiles(fileMetadataEnumerable);
59+
newInput.SupportGroup.AddFiles(Input.IncludeGroup.GetAllFileNames());
60+
newInput.SupportGroup.AddFiles(Input.SupportGroup.GetAllFileNames());
61+
Input = newInput;
62+
}
63+
}
64+
}

src/Pharmacist.Core/Extractors/PlatformExtractors/WPF.cs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,31 @@
44
// See the LICENSE file in the project root for full license information.
55

66
using System;
7-
using System.IO;
8-
using System.Linq;
9-
10-
using Pharmacist.Core.Groups;
7+
using System.Collections.Generic;
8+
using System.Threading.Tasks;
9+
using NuGet.Frameworks;
1110

1211
namespace Pharmacist.Core.Extractors.PlatformExtractors
1312
{
1413
/// <summary>
1514
/// WPF platform assemblies and events.
1615
/// </summary>
17-
internal class WPF : NetFrameworkBase
16+
internal class WPF : NetCoreExtractorBase
1817
{
19-
private static readonly string[] WantedFileNames =
20-
{
21-
"WindowsBase.dll",
22-
"PresentationCore.dll",
23-
"PresentationFramework.dll"
24-
};
25-
2618
public WPF(string? filePath)
2719
: base(filePath)
2820
{
2921
}
3022

3123
/// <inheritdoc />
32-
public override AutoPlatform Platform { get; } = AutoPlatform.WPF;
24+
public override AutoPlatform Platform => AutoPlatform.WPF;
3325

3426
/// <inheritdoc />
35-
protected override void SetFiles(InputAssembliesGroup folderGroups)
27+
protected override HashSet<string> WantedFileNames { get; } = new HashSet<string>(StringComparer.CurrentCultureIgnoreCase)
3628
{
37-
var fileMetadataEnumerable = folderGroups.IncludeGroup.GetAllFileNames().Where(file => WantedFileNames.Contains(Path.GetFileName(file), StringComparer.InvariantCultureIgnoreCase));
38-
Input.IncludeGroup.AddFiles(fileMetadataEnumerable);
39-
}
29+
"WindowsBase.dll",
30+
"PresentationCore.dll",
31+
"PresentationFramework.dll"
32+
};
4033
}
4134
}

src/Pharmacist.Core/Extractors/PlatformExtractors/Winforms.cs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,15 @@
44
// See the LICENSE file in the project root for full license information.
55

66
using System;
7-
using System.IO;
8-
using System.Linq;
9-
using Pharmacist.Core.Groups;
7+
using System.Collections.Generic;
108

119
namespace Pharmacist.Core.Extractors.PlatformExtractors
1210
{
1311
/// <summary>
1412
/// Win Forms platform assemblies and events.
1513
/// </summary>
16-
internal class Winforms : NetFrameworkBase
14+
internal class Winforms : NetCoreExtractorBase
1715
{
18-
private static readonly string[] WantedFileNames =
19-
{
20-
"System.DirectoryServices.dll",
21-
"System.Windows.Forms.dll",
22-
"System.Drawing.dll",
23-
};
24-
2516
public Winforms(string? filePath)
2617
: base(filePath)
2718
{
@@ -31,10 +22,11 @@ public Winforms(string? filePath)
3122
public override AutoPlatform Platform => AutoPlatform.Winforms;
3223

3324
/// <inheritdoc />
34-
protected override void SetFiles(InputAssembliesGroup folderGroups)
25+
protected override HashSet<string> WantedFileNames { get; } = new HashSet<string>(StringComparer.CurrentCultureIgnoreCase)
3526
{
36-
var fileMetadataEnumerable = folderGroups.IncludeGroup.GetAllFileNames().Where(file => WantedFileNames.Contains(Path.GetFileName(file), StringComparer.InvariantCultureIgnoreCase));
37-
Input.IncludeGroup.AddFiles(fileMetadataEnumerable);
38-
}
27+
"System.DirectoryServices.dll",
28+
"System.Windows.Forms.dll",
29+
"System.Drawing.dll",
30+
};
3931
}
4032
}

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.5",
2+
"version": "1.6",
33
"publicReleaseRefSpec": [
44
"^refs/heads/main$", // we release out of master
55
"^refs/heads/rel/\\d+\\.\\d+\\.\\d+" // we also release branches starting with rel/N.N.N

0 commit comments

Comments
 (0)