Skip to content

Commit

Permalink
Merge pull request #422 from punker76/feature/drop_net_452_46
Browse files Browse the repository at this point in the history
Drop .Net 4.5.2 and 4.6 target
  • Loading branch information
punker76 authored Dec 5, 2021
2 parents aa83cd5 + 67e73aa commit 641cee0
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 187 deletions.
10 changes: 5 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ branches:
only:
- develop
- main
- /\d*\.\d*\.\d*/

environment:
azure-key-vault-url:
Expand All @@ -19,18 +18,19 @@ environment:
secure: BSPdW2TgnQtoQXXbeDECug==

skip_tags: true
image: Visual Studio 2019
image: Visual Studio 2022
test: off

install:
- ps: Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile 'dotnet-install.ps1'
- ps: ./dotnet-install.ps1 -Version 6.0.100 -InstallDir "C:\Program Files\dotnet"
# install:
# - ps: Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile 'dotnet-install.ps1'
# - ps: ./dotnet-install.ps1 -Version 6.0.100 -InstallDir "C:\Program Files\dotnet"

pull_requests:
do_not_increment_build_number: false

build_script:
- ps: dotnet --list-sdks
- ps: gitversion /version
- ps: .\build.ps1 --target=ci

artifacts:
Expand Down
91 changes: 34 additions & 57 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -139,31 +139,11 @@ Task("Clean")
Task("Restore")
.Does<BuildData>(data =>
{
NuGetRestore(solution, new NuGetRestoreSettings { MSBuildPath = data.MSBuildPath.ToString() });
DotNetCoreRestore(solution);
});

Task("Build")
.Does<BuildData>(data =>
{
var msBuildSettings = new MSBuildSettings {
Verbosity = data.Verbosity
, ToolPath = data.MSBuildExe
, Configuration = data.Configuration
, ArgumentCustomization = args => args.Append("/m").Append("/nr:false") // The /nr switch tells msbuild to quite once it�s done
, BinaryLogger = new MSBuildBinaryLogSettings() { Enabled = data.IsLocalBuild }
};
MSBuild(solution, msBuildSettings
.SetMaxCpuCount(0)
.WithProperty("Version", data.IsReleaseBranch ? data.GitVersion.MajorMinorPatch : data.GitVersion.NuGetVersion)
.WithProperty("AssemblyVersion", data.GitVersion.AssemblySemVer)
.WithProperty("FileVersion", data.GitVersion.AssemblySemFileVer)
.WithProperty("InformationalVersion", data.GitVersion.InformationalVersion)
.WithProperty("ContinuousIntegrationBuild", data.IsReleaseBranch ? "true" : "false")
);
});

Task("dotnetBuild")
.Does<BuildData>(data =>
{
var buildSettings = new DotNetCoreBuildSettings {
Verbosity = data.DotNetCoreVerbosity
Expand Down Expand Up @@ -247,45 +227,43 @@ void SignFiles(IEnumerable<FilePath> files, string description)
return;
}

foreach(var file in files)
var filesToSign = string.Join(" ", files.Select(f => MakeAbsolute(f).FullPath));

var processSettings = new ProcessSettings {
RedirectStandardOutput = true,
RedirectStandardError = true,
Arguments = new ProcessArgumentBuilder()
.Append("sign")
.Append(filesToSign)
.AppendSwitchQuoted("--file-digest", "sha256")
.AppendSwitchQuoted("--description", description)
.AppendSwitchQuoted("--description-url", "https://github.com/punker76/gong-wpf-dragdrop")
.Append("--no-page-hashing")
.AppendSwitchQuoted("--timestamp-rfc3161", "http://timestamp.digicert.com")
.AppendSwitchQuoted("--timestamp-digest", "sha256")
.AppendSwitchQuoted("--azure-key-vault-url", vurl)
.AppendSwitchQuotedSecret("--azure-key-vault-client-id", vcid)
.AppendSwitchQuotedSecret("--azure-key-vault-tenant-id", vctid)
.AppendSwitchQuotedSecret("--azure-key-vault-client-secret", vcs)
.AppendSwitchQuotedSecret("--azure-key-vault-certificate", vc)
};

using(var process = StartAndReturnProcess("tools/AzureSignTool", processSettings))
{
Information($"Sign file: {file}");
var processSettings = new ProcessSettings {
RedirectStandardOutput = true,
RedirectStandardError = true,
Arguments = new ProcessArgumentBuilder()
.Append("sign")
.Append(MakeAbsolute(file).FullPath)
.AppendSwitchQuoted("--file-digest", "sha256")
.AppendSwitchQuoted("--description", description)
.AppendSwitchQuoted("--description-url", "https://github.com/punker76/gong-wpf-dragdrop")
.Append("--no-page-hashing")
.AppendSwitchQuoted("--timestamp-rfc3161", "http://timestamp.digicert.com")
.AppendSwitchQuoted("--timestamp-digest", "sha256")
.AppendSwitchQuoted("--azure-key-vault-url", vurl)
.AppendSwitchQuotedSecret("--azure-key-vault-client-id", vcid)
.AppendSwitchQuotedSecret("--azure-key-vault-tenant-id", vctid)
.AppendSwitchQuotedSecret("--azure-key-vault-client-secret", vcs)
.AppendSwitchQuotedSecret("--azure-key-vault-certificate", vc)
};
process.WaitForExit();

using(var process = StartAndReturnProcess("tools/AzureSignTool", processSettings))
if (process.GetStandardOutput().Any())
{
process.WaitForExit();

if (process.GetStandardOutput().Any())
{
Information($"Output:{Environment.NewLine}{string.Join(Environment.NewLine, process.GetStandardOutput())}");
}

if (process.GetStandardError().Any())
{
Information($"Errors occurred:{Environment.NewLine}{string.Join(Environment.NewLine, process.GetStandardError())}");
}
Information($"Output:{Environment.NewLine}{string.Join(Environment.NewLine, process.GetStandardOutput())}");
}

// This should output 0 as valid arguments supplied
Information("Exit code: {0}", process.GetExitCode());
if (process.GetStandardError().Any())
{
Information($"Errors occurred:{Environment.NewLine}{string.Join(Environment.NewLine, process.GetStandardError())}");
}

// This should output 0 as valid arguments supplied
Information("Exit code: {0}", process.GetExitCode());
}
}

Expand Down Expand Up @@ -408,8 +386,7 @@ Task("CreateRelease")
Task("Default")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
//.IsDependentOn("Build")
.IsDependentOn("dotnetBuild") // doesn't work with Fody
.IsDependentOn("Build")
;

Task("ci")
Expand Down
8 changes: 3 additions & 5 deletions src/Directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@

<!-- Project properties -->
<PropertyGroup>
<TargetFrameworks>net452;net46;net462;net47;net48;netcoreapp3.1;net5.0-windows;net6.0-windows</TargetFrameworks>
<TargetFrameworks>net462;net47;net48;netcoreapp3.1;net5.0-windows;net6.0-windows</TargetFrameworks>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<AutoGenerateBindingRedirects Condition=" $(TargetFramework.StartsWith('net4')) ">true</AutoGenerateBindingRedirects>

<AnalysisLevel>latest</AnalysisLevel>
<LangVersion>latest</LangVersion>

<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<NoError>$(NoError);CS1591</NoError>
<UseWPF>true</UseWPF>
</PropertyGroup>

<PropertyGroup>
<DefineConstants Condition="'$(TargetFramework)' == 'net5.0-windows'">$(DefineConstants);NET5_0_OR_GREATER</DefineConstants>
</PropertyGroup>

<!-- Add the references for all projects and targets -->
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2021.*" PrivateAssets="All" IncludeAssets="build;compile" />
Expand Down
32 changes: 0 additions & 32 deletions src/GongSolutions.WPF.DragDrop/Directory.Build.props

This file was deleted.

25 changes: 25 additions & 0 deletions src/GongSolutions.WPF.DragDrop/GongSolutions.WPF.DragDrop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,29 @@
<RootNamespace>GongSolutions.Wpf.DragDrop</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<!-- SourceLink -->
<PropertyGroup>
<!-- Optional: Declare that the Repository URL can be published to NuSpec -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>

<!-- Optional: Embed source files that are not tracked by the source control manager to the PDB -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>

<!-- Optional: Build symbol package (.snupkg) to distribute the PDB containing Source Link -->
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

<!-- reference includes -->
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<SourceRoot Include="$(NuGetPackageRoot)" Condition="'$(NuGetPackageRoot)' != ''" />
</ItemGroup>
</Project>
80 changes: 0 additions & 80 deletions src/GongSolutions.WPF.DragDrop/Utilities/DpiHelper.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
#if !NET462_OR_GREATER && !NETCOREAPP
using System.Reflection;
#endif
using System.Windows;
using System.Windows.Media;

Expand Down Expand Up @@ -85,82 +82,5 @@ public static Thickness LogicalThicknessToDevice(Thickness logicalThickness, dou

return new Thickness(topLeft.X, topLeft.Y, bottomRight.X, bottomRight.Y);
}

#if !NET462_OR_GREATER && !NETCOREAPP
public static double DpiX = 0d;
public static double DpiY = 0d;

[SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")]
static DpiHelper()
{
var dpiXProperty = typeof(SystemParameters).GetProperty("DpiX", BindingFlags.NonPublic | BindingFlags.Static);
var dpiYProperty = typeof(SystemParameters).GetProperty("Dpi", BindingFlags.NonPublic | BindingFlags.Static);

var pixelsPerInchX = (int)dpiXProperty.GetValue(null, null);
DpiX = (double)pixelsPerInchX;
var pixelsPerInchY = (int)dpiYProperty.GetValue(null, null);
DpiY = (double)pixelsPerInchY;
}

/// <summary>
/// Convert a point in device independent pixels (1/96") to a point in the system coordinates.
/// </summary>
/// <param name="logicalPoint">A point in the logical coordinate system.</param>
/// <returns>Returns the point converted to the system's coordinates.</returns>
public static Point LogicalPixelsToDevice(Point logicalPoint)
{
return LogicalPixelsToDevice(logicalPoint, DpiX / 96d, DpiY / 96d);
}

/// <summary>
/// Convert a point in system coordinates to a point in device independent pixels (1/96").
/// </summary>
/// <param name="devicePoint">A point in the physical coordinate system.</param>
/// <returns>Returns the point converted to the device independent coordinate system.</returns>
public static Point DevicePixelsToLogical(Point devicePoint)
{
return DevicePixelsToLogical(devicePoint, 96d / DpiX, 96d / DpiY);
}

[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static Rect LogicalRectToDevice(Rect logicalRectangle)
{
Point topLeft = LogicalPixelsToDevice(new Point(logicalRectangle.Left, logicalRectangle.Top));
Point bottomRight = LogicalPixelsToDevice(new Point(logicalRectangle.Right, logicalRectangle.Bottom));

return new Rect(topLeft, bottomRight);
}

public static Rect DeviceRectToLogical(Rect deviceRectangle)
{
Point topLeft = DevicePixelsToLogical(new Point(deviceRectangle.Left, deviceRectangle.Top));
Point bottomRight = DevicePixelsToLogical(new Point(deviceRectangle.Right, deviceRectangle.Bottom));

return new Rect(topLeft, bottomRight);
}

[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static Size LogicalSizeToDevice(Size logicalSize)
{
Point pt = LogicalPixelsToDevice(new Point(logicalSize.Width, logicalSize.Height));

return new Size { Width = pt.X, Height = pt.Y };
}

public static Size DeviceSizeToLogical(Size deviceSize)
{
Point pt = DevicePixelsToLogical(new Point(deviceSize.Width, deviceSize.Height));

return new Size(pt.X, pt.Y);
}

public static Thickness LogicalThicknessToDevice(Thickness logicalThickness)
{
Point topLeft = LogicalPixelsToDevice(new Point(logicalThickness.Left, logicalThickness.Top));
Point bottomRight = LogicalPixelsToDevice(new Point(logicalThickness.Right, logicalThickness.Bottom));

return new Thickness(topLeft.X, topLeft.Y, bottomRight.X, bottomRight.Y);
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,10 @@ private static BitmapSource CaptureScreen(Visual target, FlowDirection flowDirec
var bounds = VisualTreeHelper.GetDescendantBounds(target);
var cropBounds = VisualTreeExtensions.GetVisibleDescendantBounds(target);

#if NET461 || NET46 || NET452 || NET451 || NET45
var dpiX = DpiHelper.DpiX;
var dpiY = DpiHelper.DpiY;

var dpiBounds = DpiHelper.LogicalRectToDevice(cropBounds);
#else
var dpiScale = VisualTreeHelper.GetDpi(target);
var dpiX = dpiScale.PixelsPerInchX;
var dpiY = dpiScale.PixelsPerInchY;

var dpiBounds = DpiHelper.LogicalRectToDevice(cropBounds, dpiScale.DpiScaleX, dpiScale.DpiScaleY);
#endif

var pixelWidth = (int)Math.Ceiling(dpiBounds.Width);
var pixelHeight = (int)Math.Ceiling(dpiBounds.Height);
Expand Down

0 comments on commit 641cee0

Please sign in to comment.