Skip to content

Commit

Permalink
Fix: change wpf/winforms (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
glennawatson authored Jul 10, 2020
1 parent f4124d6 commit 6d8bb7e
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 37 deletions.
2 changes: 0 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
trigger:
- master
- main
- latest
- rel/*
- preview/*

pr:
- master
- main
- latest
- rel/*
Expand Down
2 changes: 1 addition & 1 deletion build.config
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CAKE_VERSION=0.38.1
CAKE_VERSION=0.38.4
2 changes: 1 addition & 1 deletion src/Pharmacist.Core/Extractors/NuGetExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Pharmacist.Core.Extractors
public class NuGetExtractor : IExtractor
{
/// <inheritdoc />
public InputAssembliesGroup? Input { get; private set; }
public InputAssembliesGroup? Input { get; protected set; }

/// <summary>
/// Extracts the data using the specified target framework.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// WPF platform assemblies and events.
/// </summary>
internal abstract class NetCoreExtractorBase : NuGetExtractor, IPlatformExtractor
{
private static readonly IReadOnlyList<NuGetFramework> _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();
}

/// <inheritdoc />
public NuGetFramework Framework { get; } = _frameworks[0];

/// <inheritdoc />
public abstract AutoPlatform Platform { get; }

/// <summary>
/// Gets the wanted file names.
/// </summary>
protected abstract HashSet<string> WantedFileNames { get; }

/// <inheritdoc />
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;
}
}
}
27 changes: 10 additions & 17 deletions src/Pharmacist.Core/Extractors/PlatformExtractors/WPF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/// <summary>
/// WPF platform assemblies and events.
/// </summary>
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)
{
}

/// <inheritdoc />
public override AutoPlatform Platform { get; } = AutoPlatform.WPF;
public override AutoPlatform Platform => AutoPlatform.WPF;

/// <inheritdoc />
protected override void SetFiles(InputAssembliesGroup folderGroups)
protected override HashSet<string> WantedFileNames { get; } = new HashSet<string>(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"
};
}
}
22 changes: 7 additions & 15 deletions src/Pharmacist.Core/Extractors/PlatformExtractors/Winforms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/// <summary>
/// Win Forms platform assemblies and events.
/// </summary>
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)
{
Expand All @@ -31,10 +22,11 @@ public Winforms(string? filePath)
public override AutoPlatform Platform => AutoPlatform.Winforms;

/// <inheritdoc />
protected override void SetFiles(InputAssembliesGroup folderGroups)
protected override HashSet<string> WantedFileNames { get; } = new HashSet<string>(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",
};
}
}
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 6d8bb7e

Please sign in to comment.