diff --git a/src/BizHawk.Common/BizHawk.Common.csproj b/src/BizHawk.Common/BizHawk.Common.csproj index 57addcbe31..419c498fc2 100644 --- a/src/BizHawk.Common/BizHawk.Common.csproj +++ b/src/BizHawk.Common/BizHawk.Common.csproj @@ -8,6 +8,7 @@ + diff --git a/src/BizHawk.Common/IsExternalInit.cs b/src/BizHawk.Common/IsExternalInit.cs deleted file mode 100644 index 3618710c91..0000000000 --- a/src/BizHawk.Common/IsExternalInit.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace System.Runtime.CompilerServices -{ - public static class IsExternalInit {} -} diff --git a/src/BizHawk.Common/MemoryBlock/MemoryViewStream.cs b/src/BizHawk.Common/MemoryBlock/MemoryViewStream.cs index 7eb1dc9621..43a8a73687 100644 --- a/src/BizHawk.Common/MemoryBlock/MemoryViewStream.cs +++ b/src/BizHawk.Common/MemoryBlock/MemoryViewStream.cs @@ -60,7 +60,11 @@ namespace BizHawk.Common private byte* CurrentPointer() => (byte*)Z.SS(_ptr + _pos); +#if NET6_0 + public override int Read(Span buffer) +#else public int Read(Span buffer) +#endif { if (!_readable) { @@ -106,7 +110,11 @@ namespace BizHawk.Common public override void SetLength(long value) => throw new IOException(); +#if NET6_0 + public override void Write(ReadOnlySpan buffer) +#else public void Write(ReadOnlySpan buffer) +#endif { if (!_writable) { diff --git a/src/BizHawk.Common/PropertyGridConverters/ConstrainedFloatConverter.cs b/src/BizHawk.Common/PropertyGridConverters/ConstrainedFloatConverter.cs index 0f004e793a..9b7f2ceeb6 100644 --- a/src/BizHawk.Common/PropertyGridConverters/ConstrainedFloatConverter.cs +++ b/src/BizHawk.Common/PropertyGridConverters/ConstrainedFloatConverter.cs @@ -12,14 +12,14 @@ namespace BizHawk.Common /// public class ConstrainedFloatConverter : TypeConverter { - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) { 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 + var range = (RangeAttribute)context!.Instance .GetType() .GetProperty(context.PropertyDescriptor!.Name)! .GetCustomAttributes() @@ -40,7 +40,7 @@ namespace BizHawk.Common throw new FormatException($"Invalid value: {value}, {context.PropertyDescriptor.Name} must be a float."); } - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + public override object ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) { if (destinationType == null) { diff --git a/src/BizHawk.Common/PropertyGridConverters/ConstrainedIntConverter.cs b/src/BizHawk.Common/PropertyGridConverters/ConstrainedIntConverter.cs index 5dfe2053f1..64ec3dd30e 100644 --- a/src/BizHawk.Common/PropertyGridConverters/ConstrainedIntConverter.cs +++ b/src/BizHawk.Common/PropertyGridConverters/ConstrainedIntConverter.cs @@ -12,14 +12,14 @@ namespace BizHawk.Common /// public class ConstrainedIntConverter : TypeConverter { - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) { 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 + var range = (RangeAttribute)context!.Instance .GetType() .GetProperty(context.PropertyDescriptor!.Name)! .GetCustomAttributes() @@ -40,7 +40,7 @@ namespace BizHawk.Common throw new FormatException($"Invalid value: {value}, {context.PropertyDescriptor.Name} must be an integer."); } - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + public override object ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) { if (destinationType == null) { diff --git a/src/BizHawk.Common/PropertyGridConverters/ConstrainedStringConverter.cs b/src/BizHawk.Common/PropertyGridConverters/ConstrainedStringConverter.cs index f355f1f0d3..3425fa8d36 100644 --- a/src/BizHawk.Common/PropertyGridConverters/ConstrainedStringConverter.cs +++ b/src/BizHawk.Common/PropertyGridConverters/ConstrainedStringConverter.cs @@ -12,14 +12,14 @@ namespace BizHawk.Common /// public class ConstrainedStringConverter : TypeConverter { - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) { 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 + var maxLength = (MaxLengthAttribute)context!.Instance .GetType() .GetProperty(context.PropertyDescriptor!.Name)! .GetCustomAttributes() diff --git a/src/BizHawk.Common/PropertyGridConverters/DescribableEnumConverter.cs b/src/BizHawk.Common/PropertyGridConverters/DescribableEnumConverter.cs index 463e4d6385..ff06211499 100644 --- a/src/BizHawk.Common/PropertyGridConverters/DescribableEnumConverter.cs +++ b/src/BizHawk.Common/PropertyGridConverters/DescribableEnumConverter.cs @@ -16,11 +16,11 @@ namespace BizHawk.Common enumType = type; } - public override bool CanConvertFrom(ITypeDescriptorContext context, Type srcType) => srcType == typeof(string); + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type srcType) => srcType == typeof(string); - public override bool CanConvertTo(ITypeDescriptorContext context, Type destType) => destType == typeof(string); + public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destType) => destType == typeof(string); - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object? value) { var valueStr = value?.ToString() ?? throw new ArgumentNullException(paramName: nameof(value)); return Enum.Parse( @@ -31,7 +31,7 @@ namespace BizHawk.Common ); } - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destType) + public override object ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destType) { var fieldName = Enum.GetName(enumType, value ?? throw new ArgumentNullException(paramName: nameof(value))); if (fieldName != null) @@ -47,14 +47,14 @@ namespace BizHawk.Common return value.ToString(); } - public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) => new( + public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context) => new( enumType.GetFields(BindingFlags.Public | BindingFlags.Static) .Select(fi => fi.GetValue(null)) .ToList() ); - public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) => true; + public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context) => true; - public override bool GetStandardValuesSupported(ITypeDescriptorContext context) => true; + public override bool GetStandardValuesSupported(ITypeDescriptorContext? context) => true; } } diff --git a/src/BizHawk.Common/Util.cs b/src/BizHawk.Common/Util.cs index 39b8a2f9a6..ce8f0629c7 100644 --- a/src/BizHawk.Common/Util.cs +++ b/src/BizHawk.Common/Util.cs @@ -5,6 +5,9 @@ using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; +#if NET6_0 +using System.Runtime.CompilerServices; +#endif using System.Threading; namespace BizHawk.Common @@ -79,7 +82,7 @@ namespace BizHawk.Common } #if NET6_0 - public static string DescribeIsNull(T? obj, [CallerArgumentExpression("obj")] string expr = default) + public static string DescribeIsNull(T? obj, [CallerArgumentExpression("obj")] string? expr = default) #else public static string DescribeIsNull(T? obj, string expr) #endif @@ -87,7 +90,7 @@ namespace BizHawk.Common => $"{expr} is {(obj is null ? "null" : "not null")}"; #if NET6_0 - public static string DescribeIsNullValT(T? boxed, [CallerArgumentExpression("boxed")] string expr = default) + public static string DescribeIsNullValT(T? boxed, [CallerArgumentExpression("boxed")] string? expr = default) #else public static string DescribeIsNullValT(T? boxed, string expr) #endif diff --git a/src/BizHawk.Tests/BizHawk.Tests.csproj b/src/BizHawk.Tests/BizHawk.Tests.csproj index aea54efd1d..a8af362db1 100644 --- a/src/BizHawk.Tests/BizHawk.Tests.csproj +++ b/src/BizHawk.Tests/BizHawk.Tests.csproj @@ -22,6 +22,10 @@ + + + true +