diff --git a/Common.props b/Common.props index 19bbdbbc65c..bac5ab33583 100644 --- a/Common.props +++ b/Common.props @@ -13,7 +13,7 @@ prompt strict $(TargetFramework.StartsWith("net4")) - 10.0 + 12.0 true SA0001 enable @@ -27,8 +27,7 @@ false - false - portable + none TRACE true $(MSBuildProjectDirectory)=${$(MSBuildProjectName)}/ diff --git a/Directory.Packages.props b/Directory.Packages.props index ebefb115881..a45b1e7ebc3 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -28,7 +28,7 @@ - + diff --git a/References/BizHawk.Analyzer.dll b/References/BizHawk.Analyzer.dll index 62e21f6ee46..fa830e28d01 100644 Binary files a/References/BizHawk.Analyzer.dll and b/References/BizHawk.Analyzer.dll differ diff --git a/References/BizHawk.SrcGen.ReflectionCache.dll b/References/BizHawk.SrcGen.ReflectionCache.dll index 6c08fb3ce88..7bced33335e 100644 Binary files a/References/BizHawk.SrcGen.ReflectionCache.dll and b/References/BizHawk.SrcGen.ReflectionCache.dll differ diff --git a/References/BizHawk.SrcGen.SettingsUtil.dll b/References/BizHawk.SrcGen.SettingsUtil.dll index 926863c62bb..d2321e96aad 100644 Binary files a/References/BizHawk.SrcGen.SettingsUtil.dll and b/References/BizHawk.SrcGen.SettingsUtil.dll differ diff --git a/src/BizHawk.BizInvoke/BizHawk.BizInvoke.csproj b/src/BizHawk.BizInvoke/BizHawk.BizInvoke.csproj index 27464b465d7..33c9f7ce762 100644 --- a/src/BizHawk.BizInvoke/BizHawk.BizInvoke.csproj +++ b/src/BizHawk.BizInvoke/BizHawk.BizInvoke.csproj @@ -1,6 +1,6 @@ - net48 + net48;net8.0 diff --git a/src/BizHawk.BizInvoke/BizInvoker.cs b/src/BizHawk.BizInvoke/BizInvoker.cs index 5f6c6b5dd70..b5fe2415093 100644 --- a/src/BizHawk.BizInvoke/BizInvoker.cs +++ b/src/BizHawk.BizInvoke/BizInvoker.cs @@ -600,7 +600,7 @@ private static ParameterLoadInfo EmitParamterLoad(ILGenerator il, int idx, Type il.Emit(OpCodes.Brfalse, isNull); var encoding = il.DeclareLocal(typeof(Encoding), false); - il.EmitCall(OpCodes.Call, typeof(Encoding).GetProperty("UTF8")!.GetGetMethod(), Type.EmptyTypes); + il.EmitCall(OpCodes.Call, typeof(Encoding).GetProperty("UTF8")!.GetGetMethod()!, Type.EmptyTypes); il.Emit(OpCodes.Stloc, encoding); var strlenbytes = il.DeclareLocal(typeof(int), false); @@ -632,7 +632,7 @@ private static ParameterLoadInfo EmitParamterLoad(ILGenerator il, int idx, Type il.Emit(OpCodes.Add); // charcount il.Emit(OpCodes.Ldloc, strval); - il.Emit(OpCodes.Call, typeof(string).GetProperty("Length")!.GetGetMethod()); + il.Emit(OpCodes.Call, typeof(string).GetProperty("Length")!.GetGetMethod()!); // bytes il.Emit(OpCodes.Ldloc, bytes); // bytelength diff --git a/src/BizHawk.BizInvoke/BizInvokerUtilities.cs b/src/BizHawk.BizInvoke/BizInvokerUtilities.cs index d59541c507b..82050a3ff6f 100644 --- a/src/BizHawk.BizInvoke/BizInvokerUtilities.cs +++ b/src/BizHawk.BizInvoke/BizInvokerUtilities.cs @@ -58,7 +58,7 @@ private class CF /// /// public static int ComputeClassFirstFieldOffset() - => ComputeFieldOffset(typeof(CF).GetField("FirstField")); + => ComputeFieldOffset(typeof(CF).GetField("FirstField")!); /// /// Compute the byte offset of the first byte of string data (UTF16) relative to a pointer to the string. diff --git a/src/BizHawk.BizInvoke/CallingConventionAdapter.cs b/src/BizHawk.BizInvoke/CallingConventionAdapter.cs index 4303d6fcd20..12c68d06f2d 100644 --- a/src/BizHawk.BizInvoke/CallingConventionAdapter.cs +++ b/src/BizHawk.BizInvoke/CallingConventionAdapter.cs @@ -144,7 +144,7 @@ private class WaterboxAdapter : ICallingConventionAdapter { private class ReferenceEqualityComparer : IEqualityComparer { - public bool Equals(Delegate x, Delegate y) + public bool Equals(Delegate? x, Delegate? y) => x == y; public int GetHashCode(Delegate obj) diff --git a/src/BizHawk.Bizware.Audio/BizHawk.Bizware.Audio.csproj b/src/BizHawk.Bizware.Audio/BizHawk.Bizware.Audio.csproj index a1c9b5e2577..b512cfea8c0 100644 --- a/src/BizHawk.Bizware.Audio/BizHawk.Bizware.Audio.csproj +++ b/src/BizHawk.Bizware.Audio/BizHawk.Bizware.Audio.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + netstandard2.0;net8.0 diff --git a/src/BizHawk.Bizware.BizwareGL/BizHawk.Bizware.BizwareGL.csproj b/src/BizHawk.Bizware.BizwareGL/BizHawk.Bizware.BizwareGL.csproj index 0b984476741..7db01118953 100644 --- a/src/BizHawk.Bizware.BizwareGL/BizHawk.Bizware.BizwareGL.csproj +++ b/src/BizHawk.Bizware.BizwareGL/BizHawk.Bizware.BizwareGL.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + netstandard2.0;net8.0 diff --git a/src/BizHawk.Bizware.Graphics.Controls/BizHawk.Bizware.Graphics.Controls.csproj b/src/BizHawk.Bizware.Graphics.Controls/BizHawk.Bizware.Graphics.Controls.csproj index afa42186c55..14a4c2ae3ed 100644 --- a/src/BizHawk.Bizware.Graphics.Controls/BizHawk.Bizware.Graphics.Controls.csproj +++ b/src/BizHawk.Bizware.Graphics.Controls/BizHawk.Bizware.Graphics.Controls.csproj @@ -1,14 +1,15 @@  - net48 + net48;net8.0-windows true disable + true + true - diff --git a/src/BizHawk.Bizware.Graphics/BizHawk.Bizware.Graphics.csproj b/src/BizHawk.Bizware.Graphics/BizHawk.Bizware.Graphics.csproj index 805c9754c8e..26954254d5b 100644 --- a/src/BizHawk.Bizware.Graphics/BizHawk.Bizware.Graphics.csproj +++ b/src/BizHawk.Bizware.Graphics/BizHawk.Bizware.Graphics.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + netstandard2.0;net8.0 diff --git a/src/BizHawk.Bizware.Input/BizHawk.Bizware.Input.csproj b/src/BizHawk.Bizware.Input/BizHawk.Bizware.Input.csproj index a43e7e1abb7..c4a7e9d1b46 100644 --- a/src/BizHawk.Bizware.Input/BizHawk.Bizware.Input.csproj +++ b/src/BizHawk.Bizware.Input/BizHawk.Bizware.Input.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + netstandard2.0;net8.0 diff --git a/src/BizHawk.Client.Common/Api/Classes/CommApi.cs b/src/BizHawk.Client.Common/Api/Classes/CommApi.cs index 9888dffc184..8040111b06a 100644 --- a/src/BizHawk.Client.Common/Api/Classes/CommApi.cs +++ b/src/BizHawk.Client.Common/Api/Classes/CommApi.cs @@ -20,6 +20,6 @@ public sealed class CommApi : ICommApi public string? HttpTest() => HTTP == null ? null : string.Join("\n", HttpTestGet(), HTTP.SendScreenshot(), "done testing"); - public string? HttpTestGet() => HTTP?.Get(HTTP.GetUrl)?.Result; + public string? HttpTestGet() => HttpCommunication.Get(HTTP?.GetUrl)?.Result; } } diff --git a/src/BizHawk.Client.Common/Api/ClientWebSocketWrapper.cs b/src/BizHawk.Client.Common/Api/ClientWebSocketWrapper.cs index 9f754573936..59271a390a6 100644 --- a/src/BizHawk.Client.Common/Api/ClientWebSocketWrapper.cs +++ b/src/BizHawk.Client.Common/Api/ClientWebSocketWrapper.cs @@ -32,12 +32,12 @@ public Task Close(WebSocketCloseStatus closeStatus, string statusDescription, Ca return task; } - /// calls + /// calls public Task Receive(ArraySegment buffer, CancellationToken? cancellationToken = null) => _w?.ReceiveAsync(buffer, cancellationToken ?? CancellationToken.None) ?? throw new ObjectDisposedException(nameof(_w)); - /// calls + /// calls public string Receive(int bufferCap, CancellationToken? cancellationToken = null) { if (_w == null) throw new ObjectDisposedException(nameof(_w)); @@ -46,12 +46,12 @@ public string Receive(int bufferCap, CancellationToken? cancellationToken = null return Encoding.UTF8.GetString(buffer, 0, result.Count); } - /// calls + /// calls public Task Send(ArraySegment buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken? cancellationToken = null) => _w?.SendAsync(buffer, messageType, endOfMessage, cancellationToken ?? CancellationToken.None) ?? throw new ObjectDisposedException(nameof(_w)); - /// calls + /// calls public Task Send(string message, bool endOfMessage, CancellationToken? cancellationToken = null) { if (_w == null) throw new ObjectDisposedException(nameof(_w)); diff --git a/src/BizHawk.Client.Common/Api/DisplaySurfaceID.cs b/src/BizHawk.Client.Common/Api/DisplaySurfaceID.cs index 4358fc3f5f0..39bb034ebf0 100644 --- a/src/BizHawk.Client.Common/Api/DisplaySurfaceID.cs +++ b/src/BizHawk.Client.Common/Api/DisplaySurfaceID.cs @@ -15,7 +15,7 @@ public enum DisplaySurfaceID : int public static class DisplaySurfaceIDParser { #pragma warning disable BHI1005 // switching on string, possibly from user input, ArgumentException is correct here - [return: NotNullIfNotNull("str")] + [return: NotNullIfNotNull(nameof(str))] public static DisplaySurfaceID? Parse(string? str) => str?.ToLowerInvariant() switch { null => null, // this makes it easy to cascade the "remembered" value diff --git a/src/BizHawk.Client.Common/Api/HttpCommunication.cs b/src/BizHawk.Client.Common/Api/HttpCommunication.cs index 1270b8d058c..dbc5e527b1c 100644 --- a/src/BizHawk.Client.Common/Api/HttpCommunication.cs +++ b/src/BizHawk.Client.Common/Api/HttpCommunication.cs @@ -7,7 +7,7 @@ namespace BizHawk.Client.Common { public sealed class HttpCommunication { - private readonly HttpClient _client = new HttpClient(); + public static readonly HttpClient Client = new HttpClient(); private readonly Func _takeScreenshotCallback; @@ -33,10 +33,10 @@ public string ExecPost(string url = null, string payload = "") => Post( new FormUrlEncodedContent(new Dictionary { ["payload"] = payload }) ).Result; - public async Task Get(string url) + public static async Task Get(string url) { - _client.DefaultRequestHeaders.ConnectionClose = false; - var response = await _client.GetAsync(url).ConfigureAwait(false); + Client.DefaultRequestHeaders.ConnectionClose = false; + var response = await Client.GetAsync(url).ConfigureAwait(false); if (response.IsSuccessStatusCode) { return await response.Content.ReadAsStringAsync(); @@ -44,13 +44,13 @@ public async Task Get(string url) return null; } - public async Task Post(string url, FormUrlEncodedContent content) + public static async Task Post(string url, FormUrlEncodedContent content) { - _client.DefaultRequestHeaders.ConnectionClose = true; + Client.DefaultRequestHeaders.ConnectionClose = true; HttpResponseMessage response; try { - response = await _client.PostAsync(url, content).ConfigureAwait(false); + response = await Client.PostAsync(url, content).ConfigureAwait(false); } catch (Exception e) { @@ -87,7 +87,7 @@ public void SetTimeout(int timeout) if (timeout != 0) { - _client.Timeout = new TimeSpan(0, 0, 0, timeout / 1000, timeout % 1000); + Client.Timeout = new TimeSpan(0, 0, 0, timeout / 1000, timeout % 1000); Timeout = timeout; } } diff --git a/src/BizHawk.Client.Common/BizHawk.Client.Common.csproj b/src/BizHawk.Client.Common/BizHawk.Client.Common.csproj index 526ece94b26..9372efb4452 100644 --- a/src/BizHawk.Client.Common/BizHawk.Client.Common.csproj +++ b/src/BizHawk.Client.Common/BizHawk.Client.Common.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + netstandard2.0;net8.0-windows diff --git a/src/BizHawk.Client.Common/rewind/ZeldaWinder.cs b/src/BizHawk.Client.Common/rewind/ZeldaWinder.cs index af6b8db8b24..6d6d7711b01 100644 --- a/src/BizHawk.Client.Common/rewind/ZeldaWinder.cs +++ b/src/BizHawk.Client.Common/rewind/ZeldaWinder.cs @@ -291,7 +291,11 @@ private void MaybeResize(int requestedSize) _dest = replacement; } } +#if NET6_0_OR_GREATER + public override void Write(ReadOnlySpan buffer) +#else public void Write(ReadOnlySpan buffer) +#endif { var requestedSize = _position + buffer.Length; MaybeResize(requestedSize); @@ -305,7 +309,11 @@ public override void WriteByte(byte value) _dest[_position] = value; _position = requestedSize; } +#if NET6_0_OR_GREATER + public override int Read(Span buffer) => throw new IOException(); +#else public int Read(Span buffer) => throw new IOException(); +#endif } } } diff --git a/src/BizHawk.Client.Common/rewind/ZwinderBuffer.cs b/src/BizHawk.Client.Common/rewind/ZwinderBuffer.cs index 8ac7c1f822c..c3bab2900d5 100644 --- a/src/BizHawk.Client.Common/rewind/ZwinderBuffer.cs +++ b/src/BizHawk.Client.Common/rewind/ZwinderBuffer.cs @@ -142,7 +142,7 @@ private int ComputeIdealRewindInterval() { return 1; // shrug } - + if (_fixedRewindInterval) { return _targetRewindInterval; @@ -438,14 +438,22 @@ public override void Flush() {} public override int Read(byte[] buffer, int offset, int count) => throw new IOException(); public override long Seek(long offset, SeekOrigin origin) => throw new IOException(); public override void SetLength(long value) => throw new IOException(); +#if NET6_0_OR_GREATER + public override int Read(Span buffer) => throw new IOException(); +#else public int Read(Span buffer) => throw new IOException(); +#endif public override void Write(byte[] buffer, int offset, int count) { Write(new ReadOnlySpan(buffer, offset, count)); } +#if NET6_0_OR_GREATER + public override void Write(ReadOnlySpan buffer) +#else public void Write(ReadOnlySpan buffer) +#endif { long requestedSize = _position + buffer.Length; while (requestedSize > _notifySize) @@ -521,7 +529,11 @@ public override int Read(byte[] buffer, int offset, int count) return Read(new Span(buffer, offset, count)); } +#if NET6_0_OR_GREATER + public override int Read(Span buffer) +#else public int Read(Span buffer) +#endif { long n = Math.Min(_size - _position, buffer.Length); int ret = (int)n; @@ -572,7 +584,11 @@ public override int ReadByte() public override void SetLength(long value) => throw new IOException(); public override void Write(byte[] buffer, int offset, int count) => throw new IOException(); +#if NET6_0_OR_GREATER + public override void Write(ReadOnlySpan buffer) => throw new IOException(); +#else public void Write(ReadOnlySpan buffer) => throw new IOException(); +#endif } } } diff --git a/src/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs b/src/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs index ee418b04619..8682c5d58df 100644 --- a/src/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs +++ b/src/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs @@ -149,7 +149,7 @@ public void Insert(int index, Watch watch) /// public void InsertRange(int index, IEnumerable collection) { -#if NET6_0 +#if NET6_0_OR_GREATER if (collection.TryGetNonEnumeratedCount(out var n) && n is 0) return; #else if (collection is ICollection hasCount && hasCount.Count is 0) return; diff --git a/src/BizHawk.Client.DiscoHawk/BizHawk.Client.DiscoHawk.csproj b/src/BizHawk.Client.DiscoHawk/BizHawk.Client.DiscoHawk.csproj old mode 100755 new mode 100644 index 60ba414b0a4..3cad930ed6d --- a/src/BizHawk.Client.DiscoHawk/BizHawk.Client.DiscoHawk.csproj +++ b/src/BizHawk.Client.DiscoHawk/BizHawk.Client.DiscoHawk.csproj @@ -1,27 +1,22 @@  - net48 + net48;net8.0-windows discohawk.ico disable + true + true - - - - - - - diff --git a/src/BizHawk.Client.EmuHawk/AVOut/FFmpegDownloaderForm.cs b/src/BizHawk.Client.EmuHawk/AVOut/FFmpegDownloaderForm.cs index d11feae8c59..2744905937e 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/FFmpegDownloaderForm.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/FFmpegDownloaderForm.cs @@ -160,4 +160,3 @@ private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs } } } - diff --git a/src/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/src/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj index 664aa002e65..11295d77c93 100755 --- a/src/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/src/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -1,6 +1,6 @@  - net48 + net48;net8.0-windows @@ -9,11 +9,12 @@ app.manifest disable None + true + true - - + diff --git a/src/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs b/src/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs index 29069fd3ffb..6a4bdad3e2a 100644 --- a/src/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs +++ b/src/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs @@ -31,6 +31,7 @@ public static void PopulateFromEnum(this ComboBox box, T enumVal) box.SelectedItem = enumVal.GetDescription(); } +#if !NET6_0_OR_GREATER /// extension method to make easier to use public static void Invoke(this Control control, Action action) => control.Invoke(action); @@ -38,6 +39,7 @@ public static void Invoke(this Control control, Action action) /// extension method to make easier to use public static void BeginInvoke(this Control control, Action action) => control.BeginInvoke(action); +#endif public static ToolStripMenuItem ToColumnsMenu(this InputRoll inputRoll, Action changeCallback) { diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index 87eae0f4a77..b4768be1166 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -4803,7 +4803,11 @@ private void StartSingleInstanceServer() } // Create pipe and start the async connection wait +#if NET6_0_OR_GREATER + _singleInstanceServer = NamedPipeServerStreamAcl.Create( +#else _singleInstanceServer = new NamedPipeServerStream( +#endif "pipe-{84125ACB-F570-4458-9748-321F887FE795}", PipeDirection.In, 1, diff --git a/src/BizHawk.Client.EmuHawk/UpdateChecker.cs b/src/BizHawk.Client.EmuHawk/UpdateChecker.cs index 045682a2c84..7f6c51fe526 100644 --- a/src/BizHawk.Client.EmuHawk/UpdateChecker.cs +++ b/src/BizHawk.Client.EmuHawk/UpdateChecker.cs @@ -1,6 +1,4 @@ using System; -using System.IO; -using System.Net; using System.Threading; using BizHawk.Client.Common; @@ -90,12 +88,7 @@ private static void CheckInternal() private static string DownloadURLAsString(string url) { - var request = (HttpWebRequest)WebRequest.Create(url); - request.UserAgent = "BizHawk"; - request.KeepAlive = false; - using var response = (HttpWebResponse)request.GetResponse(); - using var responseStream = new StreamReader(response.GetResponseStream()); - return responseStream.ReadToEnd(); + return HttpCommunication.Get(url).Result; } private static string ValidateVersionNumberString(string versionNumber) diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index bd1bdcddcf6..43e314ad53f 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -9,7 +9,9 @@ using BizHawk.Client.Common; using BizHawk.Common; using BizHawk.Common.CollectionExtensions; +#if !NET6_0_OR_GREATER using BizHawk.Common.StringExtensions; +#endif namespace BizHawk.Client.EmuHawk { diff --git a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.cs b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.cs index 76baba50fb5..f00af1ef236 100644 --- a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.cs +++ b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.cs @@ -78,8 +78,8 @@ public VirtualPadAnalogStick( AnalogStick.ClearCallback = ClearCallback; manualR.Maximum = Math.Max(RectToPolarHelper(RangeX.Max, RangeY.Max).R, RectToPolarHelper(RangeX.Min, RangeY.Min).R); - void UnsetLastFocusedNUD(object sender, EventArgs eventArgs) - => setLastFocusedNUD(null, null); + void UnsetLastFocusedNUD(object? sender, EventArgs eventArgs) + => setLastFocusedNUD(null, EventArgs.Empty); ManualX.ValueChanged += ManualXY_ValueChanged; ManualX.GotFocus += setLastFocusedNUD; ManualX.LostFocus += UnsetLastFocusedNUD; @@ -191,7 +191,7 @@ public void Bump(int? x, int? y) public void SetPrevious(IController previous) => AnalogStick.SetPrevious(previous); - private void ManualXY_ValueChanged(object sender, EventArgs e) + private void ManualXY_ValueChanged(object? sender, EventArgs e) { if (_updatingFromAnalog || _updatingFromPolar) return; _updatingFromXY = true; @@ -208,7 +208,7 @@ private void ManualXY_ValueChanged(object sender, EventArgs e) private void MaxManualXY_ValueChanged(object sender, EventArgs e) => AnalogStick.SetUserRange((int) MaxXNumeric.Value, (int) MaxYNumeric.Value); - private void PolarNumeric_Changed(object sender, EventArgs e) + private void PolarNumeric_Changed(object? sender, EventArgs e) { if (_updatingFromAnalog || _updatingFromXY) return; _updatingFromPolar = true; diff --git a/src/BizHawk.Common/BizHawk.Common.csproj b/src/BizHawk.Common/BizHawk.Common.csproj index 24c41336981..2c4df656364 100644 --- a/src/BizHawk.Common/BizHawk.Common.csproj +++ b/src/BizHawk.Common/BizHawk.Common.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + netstandard2.0;net8.0 @@ -16,4 +16,7 @@ + + + diff --git a/src/BizHawk.Common/Extensions/CollectionExtensions.cs b/src/BizHawk.Common/Extensions/CollectionExtensions.cs index 90c2696aaed..f15c94e7144 100644 --- a/src/BizHawk.Common/Extensions/CollectionExtensions.cs +++ b/src/BizHawk.Common/Extensions/CollectionExtensions.cs @@ -145,7 +145,7 @@ public static bool CountIsExactly(this IEnumerable collection, int n) ? countable.Count == n : collection.Take(n + 1).Count() == n; -#if !NET6_0 +#if !NET6_0_OR_GREATER /// /// Returns the value at . /// If the key is not present, returns default(TValue). @@ -188,7 +188,7 @@ public static TValue GetValueOrPutNew(this IDictionary public static TValue GetValueOrPutNew1(this IDictionary dictionary, TKey key) - => dictionary.GetValueOrPut(key, static k => (TValue) Activator.CreateInstance(typeof(TValue), k)); + => dictionary.GetValueOrPut(key, static k => (TValue) Activator.CreateInstance(typeof(TValue), k)!); /// /// @@ -212,6 +212,7 @@ public static int IndexOf(this IReadOnlyList list, T elem) return null; } +#if !NET7_0_OR_GREATER /// shorthand for this.OrderBy(static e => e), backported from .NET 7 public static IOrderedEnumerable Order(this IEnumerable source) where T : IComparable @@ -221,6 +222,7 @@ public static IOrderedEnumerable Order(this IEnumerable source) public static IOrderedEnumerable OrderDescending(this IEnumerable source) where T : IComparable => source.OrderByDescending(ReturnSelf); +#endif /// /// @@ -268,9 +270,11 @@ public static bool ReversedSequenceEqual(this ReadOnlySpan a, ReadOnlySpan return true; } +#if !NET8_0_OR_GREATER /// shallow clone public static Dictionary ToDictionary(this IEnumerable> list) => list.ToDictionary(static kvp => kvp.Key, static kvp => kvp.Value); +#endif public static bool IsSortedAsc(this IReadOnlyList list) where T : IComparable diff --git a/src/BizHawk.Common/FFmpegService.cs b/src/BizHawk.Common/FFmpegService.cs index 87e0568e655..109c11ce5ee 100644 --- a/src/BizHawk.Common/FFmpegService.cs +++ b/src/BizHawk.Common/FFmpegService.cs @@ -30,7 +30,7 @@ public class AudioQueryResult private static string[] Escape(IEnumerable args) { - return args.Select(s => s.Contains(" ") ? $"\"{s}\"" : s).ToArray(); + return args.Select(s => s.Contains(' ') ? $"\"{s}\"" : s).ToArray(); } //note: accepts . or : in the stream stream/substream separator in the stream ID format, since that changed at some point in FFMPEG history diff --git a/src/BizHawk.Common/MemoryBlock/MemoryViewStream.cs b/src/BizHawk.Common/MemoryBlock/MemoryViewStream.cs index 43a8a73687c..328549e1ec5 100644 --- a/src/BizHawk.Common/MemoryBlock/MemoryViewStream.cs +++ b/src/BizHawk.Common/MemoryBlock/MemoryViewStream.cs @@ -60,7 +60,7 @@ public override void Flush() private byte* CurrentPointer() => (byte*)Z.SS(_ptr + _pos); -#if NET6_0 +#if NET6_0_OR_GREATER public override int Read(Span buffer) #else public int Read(Span buffer) @@ -110,7 +110,7 @@ public override long Seek(long offset, SeekOrigin origin) public override void SetLength(long value) => throw new IOException(); -#if NET6_0 +#if NET6_0_OR_GREATER public override void Write(ReadOnlySpan buffer) #else public void Write(ReadOnlySpan buffer) diff --git a/src/BizHawk.Common/OSTailoredCode.cs b/src/BizHawk.Common/OSTailoredCode.cs index 5c965d21c1f..8a302ffd324 100644 --- a/src/BizHawk.Common/OSTailoredCode.cs +++ b/src/BizHawk.Common/OSTailoredCode.cs @@ -2,7 +2,9 @@ using System.Diagnostics; using System.Runtime.InteropServices; +#if !NET6_0_OR_GREATER using BizHawk.Common.StringExtensions; +#endif using static BizHawk.Common.LoaderApiImports; diff --git a/src/BizHawk.Common/PropertyGridConverters/ConstrainedFloatConverter.cs b/src/BizHawk.Common/PropertyGridConverters/ConstrainedFloatConverter.cs index 9b7f2ceeb69..1faee04eeb6 100644 --- a/src/BizHawk.Common/PropertyGridConverters/ConstrainedFloatConverter.cs +++ b/src/BizHawk.Common/PropertyGridConverters/ConstrainedFloatConverter.cs @@ -17,7 +17,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext? context, Type source return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); } - public override object ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object? value) + public override object ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) { var range = (RangeAttribute)context!.Instance .GetType() diff --git a/src/BizHawk.Common/PropertyGridConverters/ConstrainedIntConverter.cs b/src/BizHawk.Common/PropertyGridConverters/ConstrainedIntConverter.cs index 64ec3dd30e1..2a296e91bc5 100644 --- a/src/BizHawk.Common/PropertyGridConverters/ConstrainedIntConverter.cs +++ b/src/BizHawk.Common/PropertyGridConverters/ConstrainedIntConverter.cs @@ -17,7 +17,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext? context, Type source return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); } - public override object ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object? value) + public override object ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) { var range = (RangeAttribute)context!.Instance .GetType() diff --git a/src/BizHawk.Common/PropertyGridConverters/ConstrainedStringConverter.cs b/src/BizHawk.Common/PropertyGridConverters/ConstrainedStringConverter.cs index 3425fa8d365..62328ce620f 100644 --- a/src/BizHawk.Common/PropertyGridConverters/ConstrainedStringConverter.cs +++ b/src/BizHawk.Common/PropertyGridConverters/ConstrainedStringConverter.cs @@ -17,7 +17,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext? context, Type source return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); } - public override object ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object? value) + public override object ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) { var maxLength = (MaxLengthAttribute)context!.Instance .GetType() @@ -32,7 +32,7 @@ public override object ConvertFrom(ITypeDescriptorContext? context, CultureInfo? throw new FormatException($"{context.PropertyDescriptor.Name} can not be null"); } - return value.ToString(); + return value.ToString()!; } } } diff --git a/src/BizHawk.Common/PropertyGridConverters/DescribableEnumConverter.cs b/src/BizHawk.Common/PropertyGridConverters/DescribableEnumConverter.cs index ff062114993..4af54d13a4b 100644 --- a/src/BizHawk.Common/PropertyGridConverters/DescribableEnumConverter.cs +++ b/src/BizHawk.Common/PropertyGridConverters/DescribableEnumConverter.cs @@ -40,11 +40,11 @@ public override object ConvertTo(ITypeDescriptorContext? context, CultureInfo? c if (fieldInfo != null) { var found = fieldInfo.GetCustomAttribute(typeof(DisplayAttribute)); - if (found is DisplayAttribute da) return da.Name; + if (found is DisplayAttribute da) return da.Name!; } } - return value.ToString(); + return value.ToString()!; } public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context) => new( diff --git a/src/BizHawk.Common/Serializer.cs b/src/BizHawk.Common/Serializer.cs index 9190eb916a0..c1057e0b7b9 100644 --- a/src/BizHawk.Common/Serializer.cs +++ b/src/BizHawk.Common/Serializer.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; - +using System.Text.RegularExpressions; using BizHawk.Common.IOExtensions; using BizHawk.Common.BufferExtensions; diff --git a/src/BizHawk.Common/Util.cs b/src/BizHawk.Common/Util.cs index ce8f0629c73..2b647c32c50 100644 --- a/src/BizHawk.Common/Util.cs +++ b/src/BizHawk.Common/Util.cs @@ -5,7 +5,7 @@ using System.IO.Compression; using System.Linq; using System.Reflection; -#if NET6_0 +#if NET6_0_OR_GREATER using System.Runtime.CompilerServices; #endif using System.Threading; @@ -81,16 +81,16 @@ public static bool DictionaryEqual(IDictionary a, ID return a.All(kvp => b.TryGetValue(kvp.Key, out var bVal) && comparer.Equals(kvp.Value, bVal)); } -#if NET6_0 - public static string DescribeIsNull(T? obj, [CallerArgumentExpression("obj")] string? expr = default) +#if NET6_0_OR_GREATER + public static string DescribeIsNull(T? obj, [CallerArgumentExpression(nameof(obj))] string? expr = default) #else public static string DescribeIsNull(T? obj, string expr) #endif where T : class => $"{expr} is {(obj is null ? "null" : "not null")}"; -#if NET6_0 - public static string DescribeIsNullValT(T? boxed, [CallerArgumentExpression("boxed")] string? expr = default) +#if NET6_0_OR_GREATER + public static string DescribeIsNullValT(T? boxed, [CallerArgumentExpression(nameof(boxed))] string? expr = default) #else public static string DescribeIsNullValT(T? boxed, string expr) #endif @@ -122,7 +122,7 @@ public static IEnumerable GetTypesWithoutLoadErrors(this Assembly assembly } catch (ReflectionTypeLoadException e) { - return e.Types.Where(t => t != null); + return e.Types.Where(t => t != null)!; } } diff --git a/src/BizHawk.Common/checksums/MD5Checksum.cs b/src/BizHawk.Common/checksums/MD5Checksum.cs index d13f2aa5f57..1db0f6791b2 100644 --- a/src/BizHawk.Common/checksums/MD5Checksum.cs +++ b/src/BizHawk.Common/checksums/MD5Checksum.cs @@ -19,7 +19,7 @@ public static class MD5Checksum public /*static readonly*/const string EmptyFile = "D41D8CD98F00B204E9800998ECF8427E"; -#if NET6_0 +#if NET6_0_OR_GREATER public static byte[] Compute(ReadOnlySpan data) => MD5.HashData(data); #else diff --git a/src/BizHawk.Common/checksums/SHA1Checksum.cs b/src/BizHawk.Common/checksums/SHA1Checksum.cs index 00920f3549e..cfe424d8b1a 100644 --- a/src/BizHawk.Common/checksums/SHA1Checksum.cs +++ b/src/BizHawk.Common/checksums/SHA1Checksum.cs @@ -25,7 +25,7 @@ public static class SHA1Checksum public /*static readonly*/const string Zero = "0000000000000000000000000000000000000000"; -#if NET6_0 +#if NET6_0_OR_GREATER public static byte[] Compute(ReadOnlySpan data) => SHA1.HashData(data); diff --git a/src/BizHawk.Common/checksums/SHA256Checksum.cs b/src/BizHawk.Common/checksums/SHA256Checksum.cs index f27d9b53ff7..1c48bfde8f2 100644 --- a/src/BizHawk.Common/checksums/SHA256Checksum.cs +++ b/src/BizHawk.Common/checksums/SHA256Checksum.cs @@ -19,7 +19,7 @@ public static class SHA256Checksum public /*static readonly*/const string EmptyFile = "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"; -#if NET6_0 +#if NET6_0_OR_GREATER public static byte[] Compute(ReadOnlySpan data) => SHA256.HashData(data); #else diff --git a/src/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj b/src/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj index 8790dd2cae6..78a6fce58dc 100644 --- a/src/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj +++ b/src/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + netstandard2.0;net8.0 diff --git a/src/BizHawk.Emulation.Common/Database/FirmwareID.cs b/src/BizHawk.Emulation.Common/Database/FirmwareID.cs index 70173dc9c45..79a849ced92 100644 --- a/src/BizHawk.Emulation.Common/Database/FirmwareID.cs +++ b/src/BizHawk.Emulation.Common/Database/FirmwareID.cs @@ -28,7 +28,7 @@ static bool IsAllowedCharacter(char c) Firmware = firmware; } - public override bool Equals(object obj) => obj is FirmwareID other + public override bool Equals(object? obj) => obj is FirmwareID other && other.Firmware == Firmware && other.System == System; public override int GetHashCode() => (System, Firmware).GetHashCode(); diff --git a/src/BizHawk.Emulation.Common/VSystemID.cs b/src/BizHawk.Emulation.Common/VSystemID.cs index 86a3c6dd767..730145dfe33 100644 --- a/src/BizHawk.Emulation.Common/VSystemID.cs +++ b/src/BizHawk.Emulation.Common/VSystemID.cs @@ -78,7 +78,7 @@ public static class Raw private static List AllSysIDs => _allSysIDs ??= typeof(Raw).GetFields(BindingFlags.Public | BindingFlags.Static) - .Select(x => (string) x.GetRawConstantValue()) + .Select(x => (string) x.GetRawConstantValue()!) .Order().ToList(); /// iff it's in the valid list, else diff --git a/src/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/src/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index 3657b7a326e..a1ebc8ba753 100644 --- a/src/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/src/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + netstandard2.0;net8.0 diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs index 7384e398f03..4190f4dfcd7 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs @@ -1145,7 +1145,7 @@ public bool ReadPort(ushort port, ref int result) public bool WritePort(ushort port, int result) { BitArray portBits = new BitArray(BitConverter.GetBytes(port)); - BitArray dataBits = new BitArray(BitConverter.GetBytes((byte)result)); + BitArray dataBits = new BitArray(new[] {(byte)result}); byte portUpper = (byte)(port >> 8); byte portLower = (byte)(port & 0xff); diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC464/CPC464.Port.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC464/CPC464.Port.cs index 9d2d10e321f..b6abc8b0a56 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC464/CPC464.Port.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC464/CPC464.Port.cs @@ -55,7 +55,7 @@ public override byte ReadPort(ushort port) public override void WritePort(ushort port, byte value) { BitArray portBits = new BitArray(BitConverter.GetBytes(port)); - BitArray dataBits = new BitArray(BitConverter.GetBytes(value)); + BitArray dataBits = new BitArray(new[] {value}); byte portUpper = (byte)(port >> 8); byte portLower = (byte)(port & 0xff); diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC6128/CPC6128.Port.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC6128/CPC6128.Port.cs index 6cd4c5706c9..6453f7f5288 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC6128/CPC6128.Port.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC6128/CPC6128.Port.cs @@ -69,7 +69,7 @@ public override byte ReadPort(ushort port) public override void WritePort(ushort port, byte value) { BitArray portBits = new BitArray(BitConverter.GetBytes(port)); - BitArray dataBits = new BitArray(BitConverter.GetBytes(value)); + BitArray dataBits = new BitArray(new[] {value}); byte portUpper = (byte)(port >> 8); byte portLower = (byte)(port & 0xff); diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/GateArrayBase.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/GateArrayBase.cs index 71cf090839d..07acd9eafcb 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/GateArrayBase.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/GateArrayBase.cs @@ -362,7 +362,7 @@ public bool ReadPort(ushort port, ref int result) public bool WritePort(ushort port, int result) { BitArray portBits = new BitArray(BitConverter.GetBytes(port)); - BitArray dataBits = new BitArray(BitConverter.GetBytes((byte)result)); + BitArray dataBits = new BitArray(new[] {(byte)result}); // The gate array responds to port 0x7F bool accessed = !portBits[15]; diff --git a/src/BizHawk.Emulation.DiscSystem/BizHawk.Emulation.DiscSystem.csproj b/src/BizHawk.Emulation.DiscSystem/BizHawk.Emulation.DiscSystem.csproj index 386fc884ba9..1852b7c515f 100644 --- a/src/BizHawk.Emulation.DiscSystem/BizHawk.Emulation.DiscSystem.csproj +++ b/src/BizHawk.Emulation.DiscSystem/BizHawk.Emulation.DiscSystem.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + netstandard2.0;net8.0 diff --git a/src/BizHawk.WinForms.Controls/BizHawk.WinForms.Controls.csproj b/src/BizHawk.WinForms.Controls/BizHawk.WinForms.Controls.csproj index db07bf00139..1d7f4938307 100644 --- a/src/BizHawk.WinForms.Controls/BizHawk.WinForms.Controls.csproj +++ b/src/BizHawk.WinForms.Controls/BizHawk.WinForms.Controls.csproj @@ -1,10 +1,13 @@  - net48 + net48;net8.0-windows + + true + true + - diff --git a/src/MainSlnCommon.props b/src/MainSlnCommon.props index 98c37b94f49..336b77c4c4c 100644 --- a/src/MainSlnCommon.props +++ b/src/MainSlnCommon.props @@ -1,11 +1,9 @@ - false $(DefineConstants);AVI_SUPPORT $(MSBuildProjectDirectory)/bin/doc_comments.xml $(NoWarn);CS1573;CS1591;NU1702 - $(MSBuildProjectDirectory)/../../output/dll None diff --git a/src/MainSlnExecutable.props b/src/MainSlnExecutable.props index fad2ae8c1c4..b5bc66ec4ce 100644 --- a/src/MainSlnExecutable.props +++ b/src/MainSlnExecutable.props @@ -3,6 +3,7 @@ $(MSBuildProjectDirectory)/../../output $(MSBuildProjectName.Substring($([MSBuild]::Add($(MSBuildProjectName.LastIndexOf('.')), 1)))) + $(AssemblyName) Exe @@ -13,10 +14,10 @@ - + - +