Skip to content

Commit

Permalink
Upgrade to NET7
Browse files Browse the repository at this point in the history
  • Loading branch information
iXab3r committed Feb 24, 2023
1 parent 5c0c2c5 commit 06e53ab
Show file tree
Hide file tree
Showing 13 changed files with 710 additions and 89 deletions.
2 changes: 1 addition & 1 deletion PoeEye/PoeShared.Benchmarks/PoeShared.Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6-windows10.0.20348.0</TargetFramework>
<TargetFramework>net7-windows10.0.20348.0</TargetFramework>
<IsPackable>false</IsPackable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWPF>true</UseWPF>
Expand Down
2 changes: 1 addition & 1 deletion PoeEye/PoeShared.Blazor.Wpf/PoeShared.Blazor.Wpf.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6-windows10.0.20348.0</TargetFramework>
<TargetFramework>net7-windows7.0</TargetFramework>
<AssemblyTitle>PoeShared.Blazor</AssemblyTitle>
<Product>PoeShared.Blazor</Product>
<Copyright>Copyright © Xab3r 2022</Copyright>
Expand Down
21 changes: 13 additions & 8 deletions PoeEye/PoeShared.Native/PoeShared.Native.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<CefSharpAnyCpuSupport>true</CefSharpAnyCpuSupport>
<ProjectGuid>{9AAA9005-0177-4F4C-B6DE-EB09037DB155}</ProjectGuid>
<TargetFramework>net6-windows7</TargetFramework>
<TargetFramework>net7-windows</TargetFramework>
<AssemblyTitle>PoeShared</AssemblyTitle>
<Product>PoeShared</Product>
<Description>PoeEye Shared classes</Description>
Expand All @@ -19,28 +19,33 @@
<PackageReference Include="CommonServiceLocator" Version="2.0.4" />
<PackageReference Include="CompareNETObjects" Version="4.65.0" />
<PackageReference Include="CSCore" Version="1.2.1.2" />
<PackageReference Include="Guards" Version="1.0.10"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="NAudio" Version="2.0.1"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="NAudio" Version="2.0.1">
<NoWarn>NU1701</NoWarn>
</PackageReference>
<PackageReference Include="PInvoke.DwmApi" Version="0.6.49" />
<PackageReference Include="PInvoke.Hid" Version="0.6.49" />
<PackageReference Include="PInvoke.Kernel32" Version="0.6.49" />
<PackageReference Include="PInvoke.SetupApi" Version="0.6.49" />
<PackageReference Include="PInvoke.User32" Version="0.6.49" />
<PackageReference Include="PInvoke.Gdi32" Version="0.6.49" />
<PackageReference Include="Prism.Core" Version="7.2.0.1367" />
<PackageReference Include="Prism.Unity" Version="7.2.0.1367" />
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0" PrivateAssets="All"><ExcludeAssets>runtime</ExcludeAssets><IncludeAssets>All</IncludeAssets></PackageReference>
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0" PrivateAssets="All">
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>All</IncludeAssets>
</PackageReference>
<PackageReference Include="RestEase" Version="1.4.10" />
<PackageReference Include="SevenZipSharp.Interop" Version="19.0.1" />
<PackageReference Include="StartupHelper" Version="1.0.2.0"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="System.Drawing.Primitives" Version="4.3.0" />
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="5.0.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="Windows-Forms-Aero" Version="3.1.1" />
<PackageReference Include="Guards" Version="1.0.15" />
<PackageReference Include="StartupHelper" Version="1.0.3.4" />
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.410601">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Notifications\mercury.wav" />
Expand Down
83 changes: 43 additions & 40 deletions PoeEye/PoeShared.Squirrel/PoeShared.Squirrel.csproj
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<UseWPF>true</UseWPF>
<IsPackable>false</IsPackable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU</Platforms>
<LangVersion>10</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<TargetFramework>net6-windows10.0.20348.0</TargetFramework>
<NoWarn>CA1416;NU1701;CS0649;CS0414;CS1998</NoWarn>
</PropertyGroup>

<ItemGroup>
<SupportedPlatform Include="windows" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="DeltaCompressionDotNet" Version="2.0.0"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="Microsoft.Data.OData" Version="5.6.1" />
<PackageReference Include="Mono.Cecil" Version="0.11.3" />
<PackageReference Include="Prism.Core" Version="7.2.0.1367" />
<PackageReference Include="Prism.Unity" Version="7.2.0.1367" />
<PackageReference Include="Prism.Wpf" Version="7.2.0.1367" />
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0" PrivateAssets="All"><ExcludeAssets>runtime</ExcludeAssets><IncludeAssets>All</IncludeAssets></PackageReference>
<PackageReference Include="SpicyTaco.AutoGrid" Version="1.2.29"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="squirrel.windows" Version="1.9.0"><NoWarn>NU1701;NU1608</NoWarn></PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\PoeShared.Squirrel.Shared\PoeShared.Squirrel.Shared.csproj" />
<ProjectReference Include="..\PoeShared\PoeShared.csproj" />
<ProjectReference Include="..\PoeShared.Native\PoeShared.Native.csproj" />
<ProjectReference Include="..\PoeShared.Wpf\PoeShared.Wpf.csproj" />
</ItemGroup>

</Project>
<PropertyGroup>
<UseWPF>true</UseWPF>
<IsPackable>false</IsPackable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU</Platforms>
<LangVersion>10</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<TargetFramework>net7-windows</TargetFramework>
<NoWarn>CA1416;NU1701;CS0649;CS0414;CS1998</NoWarn>
</PropertyGroup>
<ItemGroup>
<SupportedPlatform Include="windows" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="Mono.Cecil" Version="0.11.3" />
<PackageReference Include="Prism.Unity" Version="7.2.0.1367" />
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0" PrivateAssets="All">
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>All</IncludeAssets>
</PackageReference>
<PackageReference Include="SpicyTaco.AutoGrid" Version="1.2.29">
<NoWarn>NU1701</NoWarn>
</PackageReference>
<PackageReference Include="squirrel.windows" Version="1.9.0">
<NoWarn>NU1701;NU1608</NoWarn>
</PackageReference>
<PackageReference Include="DeltaCompressionDotNet" Version="2.0.1" />
<PackageReference Include="Microsoft.Data.OData" Version="5.8.5" />
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.410601">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PoeShared.Squirrel.Shared\PoeShared.Squirrel.Shared.csproj" />
<ProjectReference Include="..\PoeShared\PoeShared.csproj" />
<ProjectReference Include="..\PoeShared.Native\PoeShared.Native.csproj" />
<ProjectReference Include="..\PoeShared.Wpf\PoeShared.Wpf.csproj" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion PoeEye/PoeShared.Tests/PoeShared.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6-windows10.0.20348.0</TargetFramework>
<TargetFramework>net7-windows10.0.20348.0</TargetFramework>
<IsPackable>false</IsPackable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWPF>true</UseWPF>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Collections.ObjectModel;
using System.Threading;
using System.Threading.Tasks;
using ABI.Windows.ApplicationModel.Email;
using DynamicData;
using PoeShared.Scaffolding;
using Shouldly;
Expand Down
2 changes: 1 addition & 1 deletion PoeEye/PoeShared.UI/PoeShared.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Platforms>AnyCPU</Platforms>
<LangVersion>10</LangVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<TargetFramework>net6.0-windows10.0.20348.0</TargetFramework>
<TargetFramework>net7-windows</TargetFramework>
<ApplicationIcon>Resources/mainIconAlt.ico</ApplicationIcon>
<NoWarn>CA1416;NU1701;CS0649;CS0414;CS1998</NoWarn>
</PropertyGroup>
Expand Down
208 changes: 208 additions & 0 deletions PoeEye/PoeShared.Wpf/Modularity/DispatcherScheduler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
using System;
using System.Reactive.Concurrency;
using System.Threading;
using System.Windows.Threading;
using System.Reactive.Disposables;

namespace PoeShared.Modularity;

/// <summary>
/// Represents an object that schedules units of work on a <see cref="System.Windows.Threading.Dispatcher"/>.
/// </summary>
/// <remarks>
/// This scheduler type is typically used indirectly through the <see cref="Linq.DispatcherObservable.ObserveOnDispatcher{TSource}(IObservable{TSource})"/> and <see cref="Linq.DispatcherObservable.SubscribeOnDispatcher{TSource}(IObservable{TSource})"/> methods that use the Dispatcher on the calling thread.
/// </remarks>
public sealed class DispatcherScheduler : LocalScheduler, ISchedulerPeriodic
{

/// <summary>
/// Gets the scheduler that schedules work on the <see cref="System.Windows.Threading.Dispatcher"/> for the current thread.
/// </summary>
public static DispatcherScheduler Current
{
get
{
var dispatcher = System.Windows.Threading.Dispatcher.FromThread(Thread.CurrentThread);
if (dispatcher == null)
{
throw new InvalidOperationException("NO_DISPATCHER_CURRENT_THREAD");
}

return new DispatcherScheduler(dispatcher);
}
}

/// <summary>
/// Constructs a <see cref="DispatcherScheduler"/> that schedules units of work on the given <see cref="System.Windows.Threading.Dispatcher"/>.
/// </summary>
/// <param name="dispatcher"><see cref="DispatcherScheduler"/> to schedule work on.</param>
/// <exception cref="ArgumentNullException"><paramref name="dispatcher"/> is <c>null</c>.</exception>
public DispatcherScheduler(System.Windows.Threading.Dispatcher dispatcher)
{
Dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher));
Priority = System.Windows.Threading.DispatcherPriority.Normal;

}

/// <summary>
/// Constructs a <see cref="DispatcherScheduler"/> that schedules units of work on the given <see cref="System.Windows.Threading.Dispatcher"/> at the given priority.
/// </summary>
/// <param name="dispatcher"><see cref="DispatcherScheduler"/> to schedule work on.</param>
/// <param name="priority">Priority at which units of work are scheduled.</param>
/// <exception cref="ArgumentNullException"><paramref name="dispatcher"/> is <c>null</c>.</exception>
public DispatcherScheduler(System.Windows.Threading.Dispatcher dispatcher, System.Windows.Threading.DispatcherPriority priority)
{
Dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher));
Priority = priority;
}

/// <summary>
/// Gets the <see cref="System.Windows.Threading.Dispatcher"/> associated with the <see cref="DispatcherScheduler"/>.
/// </summary>
public System.Windows.Threading.Dispatcher Dispatcher { get; }

/// <summary>
/// Gets the priority at which work items will be dispatched.
/// </summary>
public System.Windows.Threading.DispatcherPriority Priority { get; }

/// <summary>
/// Schedules an action to be executed on the dispatcher.
/// </summary>
/// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
/// <param name="state">State passed to the action to be executed.</param>
/// <param name="action">Action to be executed.</param>
/// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
/// <exception cref="ArgumentNullException"><paramref name="action"/> is <c>null</c>.</exception>
public override IDisposable Schedule<TState>(TState state, Func<IScheduler, TState, IDisposable> action)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}

var d = new SingleAssignmentDisposable();

Dispatcher.BeginInvoke(
new Action(() =>
{
if (!d.IsDisposed)
{
d.Disposable = action(this, state);
}
}),
Priority
);

return d;
}

/// <summary>
/// Schedules an action to be executed after <paramref name="dueTime"/> on the dispatcher, using a <see cref="System.Windows.Threading.DispatcherTimer"/> object.
/// </summary>
/// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
/// <param name="state">State passed to the action to be executed.</param>
/// <param name="action">Action to be executed.</param>
/// <param name="dueTime">Relative time after which to execute the action.</param>
/// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
/// <exception cref="ArgumentNullException"><paramref name="action"/> is <c>null</c>.</exception>
public override IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}

var dt = Scheduler.Normalize(dueTime);
if (dt.Ticks == 0)
{
return Schedule(state, action);
}

return ScheduleSlow(state, dt, action);
}

private IDisposable ScheduleSlow<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action)
{
var d = new MultipleAssignmentDisposable();

var timer = new System.Windows.Threading.DispatcherTimer(Priority, Dispatcher);

timer.Tick += (s, e) =>
{
var t = Interlocked.Exchange(ref timer, null);
if (t != null)
{
try
{
d.Disposable = action(this, state);
}
finally
{
t.Stop();
action = static (s, t) => Disposable.Empty;
}
}
};

timer.Interval = dueTime;
timer.Start();

d.Disposable = Disposable.Create(() =>
{
var t = Interlocked.Exchange(ref timer, null);
if (t != null)
{
t.Stop();
action = static (s, t) => Disposable.Empty;
}
});

return d;
}

/// <summary>
/// Schedules a periodic piece of work on the dispatcher, using a <see cref="System.Windows.Threading.DispatcherTimer"/> object.
/// </summary>
/// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
/// <param name="state">Initial state passed to the action upon the first iteration.</param>
/// <param name="period">Period for running the work periodically.</param>
/// <param name="action">Action to be executed, potentially updating the state.</param>
/// <returns>The disposable object used to cancel the scheduled recurring action (best effort).</returns>
/// <exception cref="ArgumentNullException"><paramref name="action"/> is <c>null</c>.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="period"/> is less than <see cref="TimeSpan.Zero"/>.</exception>
public IDisposable SchedulePeriodic<TState>(TState state, TimeSpan period, Func<TState, TState> action)
{
if (period < TimeSpan.Zero)
{
throw new ArgumentOutOfRangeException(nameof(period));
}

if (action == null)
{
throw new ArgumentNullException(nameof(action));
}

var timer = new System.Windows.Threading.DispatcherTimer(Priority, Dispatcher);

var state1 = state;

timer.Tick += (s, e) =>
{
state1 = action(state1);
};

timer.Interval = period;
timer.Start();

return Disposable.Create(() =>
{
var t = Interlocked.Exchange(ref timer, null);
if (t != null)
{
t.Stop();
action = static _ => _;
}
});
}
}
1 change: 1 addition & 0 deletions PoeEye/PoeShared.Wpf/Native/ConstantAspectRatioWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using PoeShared.Scaffolding;
using PoeShared.Logging;
using PoeShared.UI;
using PoeShared.Modularity;

namespace PoeShared.Native;

Expand Down
Loading

0 comments on commit 06e53ab

Please sign in to comment.