diff --git a/scripts/Build.ps1 b/scripts/Build.ps1 index 16a87c2..425b777 100644 --- a/scripts/Build.ps1 +++ b/scripts/Build.ps1 @@ -1,7 +1,6 @@ . $PSScriptRoot\Variables.ps1 Push-Location $SolutionDir -$Env:Platform = '' foreach ($project in $Projects) { dotnet build --no-restore -c Debug .\$project\$project.csproj diff --git a/scripts/Clean.ps1 b/scripts/Clean.ps1 index 1002e0b..5b51a75 100644 --- a/scripts/Clean.ps1 +++ b/scripts/Clean.ps1 @@ -1,18 +1,17 @@ . $PSScriptRoot\Variables.ps1 Push-Location $SolutionDir -$Env:Platform = '' foreach ($project in $Projects) { dotnet clean -c Release .\$project\$project.csproj dotnet clean -c Debug .\$project\$project.csproj } -$Env:Platform = 'x64' -foreach ($project in $Projects) -{ - dotnet clean -c Release .\$project\$project.csproj - dotnet clean -c Debug .\$project\$project.csproj -} +# $Env:Platform = 'x64' +# foreach ($project in $Projects) +# { +# dotnet clean -c Release .\$project\$project.csproj +# dotnet clean -c Debug .\$project\$project.csproj +# } Pop-Location diff --git a/scripts/CleanAll.ps1 b/scripts/CleanAll.ps1 index 7abba4c..67e28df 100644 --- a/scripts/CleanAll.ps1 +++ b/scripts/CleanAll.ps1 @@ -1,12 +1,11 @@ . $PSScriptRoot\Variables.ps1 Push-Location $SolutionDir -$Env:Platform = '' - dotnet clean -c Release - dotnet clean -c Debug +dotnet clean -c Release +dotnet clean -c Debug -$Env:Platform = 'x64' - dotnet clean -c Release - dotnet clean -c Debug +# $Env:Platform = 'x64' +# dotnet clean -c Release +# dotnet clean -c Debug Pop-Location diff --git a/scripts/Pack.ps1 b/scripts/Pack.ps1 index 4a42740..74ecf96 100644 --- a/scripts/Pack.ps1 +++ b/scripts/Pack.ps1 @@ -3,7 +3,6 @@ Push-Location $SolutionDir if (!(Test-Path -PathType Container $ArtifactsDir)) { New-Item -ItemType Directory -Path $ArtifactsDir } -$Env:Platform = '' foreach ($project in $Projects) { dotnet pack --no-build -c Release -o $ArtifactsDir "-p:Version=$Env:GitVersion_NuGetVersionV2" .\$project\$project.csproj if (!$?) { throw } diff --git a/scripts/PublishNuget.ps1 b/scripts/PublishNuget.ps1 index 6243676..601a9dc 100644 --- a/scripts/PublishNuget.ps1 +++ b/scripts/PublishNuget.ps1 @@ -1,6 +1,5 @@ . $PSScriptRoot\Variables.ps1 Push-Location $SolutionDir -$Env:Platform = '' foreach ($project in $Projects) { dotnet nuget push ".\artifacts\$project.$Env:GitVersion_NuGetVersionV2.nupkg" --skip-duplicate --api-key $env:NUGET_API_KEY --source https://api.nuget.org/v3/index.json diff --git a/src/NullGC.Abstractions/Collections/IUnsafeArray.cs b/src/NullGC.Abstractions/Collections/IUnsafeArray.cs index ff22882..19b1c2e 100644 --- a/src/NullGC.Abstractions/Collections/IUnsafeArray.cs +++ b/src/NullGC.Abstractions/Collections/IUnsafeArray.cs @@ -6,9 +6,11 @@ public interface IUnsafeArray /// /// /// - /// unmanaged constraint is not added to facilitate < + /// unmanaged constraint is not added to allow potential fixable managed pointer implementations. /// +#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type unsafe T* Items { get; } +#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type int Length { get; } bool IsInitialized { get; } } \ No newline at end of file diff --git a/src/NullGC.Abstractions/Extensions/CollectionExtensions.cs b/src/NullGC.Abstractions/Extensions/CollectionExtensions.cs index 926c2e4..964e3a6 100644 --- a/src/NullGC.Abstractions/Extensions/CollectionExtensions.cs +++ b/src/NullGC.Abstractions/Extensions/CollectionExtensions.cs @@ -15,7 +15,7 @@ public static ref TValue GetValueRefOrNullRef(this Dictionary(this Dictionary dict, TKey key, out bool exist) where TKey : notnull diff --git a/src/NullGC.Abstractions/FuncInvokers.cs b/src/NullGC.Abstractions/FuncInvokers.cs index 4060e59..fddf70a 100644 --- a/src/NullGC.Abstractions/FuncInvokers.cs +++ b/src/NullGC.Abstractions/FuncInvokers.cs @@ -1,4 +1,5 @@ using System.Runtime.CompilerServices; +#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type namespace NullGC; @@ -387,7 +388,7 @@ public int Compare(RawKeyValuePair a, RawKeyValuePair comparer) => _comparer = comparer; [MethodImpl(MethodImplOptions.AggressiveInlining)] - public int Compare(T? x, T? y) => _comparer(x, y); + public int Compare(T? x, T? y) => _comparer(x!, y!); } public struct StructComparerWithPtrArg : IComparer where TArg : unmanaged @@ -410,7 +411,7 @@ public int Compare(T? x, T? y) { unsafe { - return _comparer(x, y, ref Unsafe.AsRef(_arg)); + return _comparer(x!, y!, ref Unsafe.AsRef(_arg)); } } } diff --git a/src/NullGC.Abstractions/Linq/ILinqRefEnumerator.cs b/src/NullGC.Abstractions/Linq/ILinqRefEnumerator.cs index b879dfb..372eeb1 100644 --- a/src/NullGC.Abstractions/Linq/ILinqRefEnumerator.cs +++ b/src/NullGC.Abstractions/Linq/ILinqRefEnumerator.cs @@ -3,5 +3,7 @@ public interface ILinqRefEnumerator : ILinqEnumerator { new ref T Current { get; } +#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type unsafe T* CurrentPtr { get; } +#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type } \ No newline at end of file diff --git a/src/NullGC.Abstractions/NullGC.Abstractions.csproj b/src/NullGC.Abstractions/NullGC.Abstractions.csproj index b819555..62a2049 100644 --- a/src/NullGC.Abstractions/NullGC.Abstractions.csproj +++ b/src/NullGC.Abstractions/NullGC.Abstractions.csproj @@ -14,10 +14,10 @@ - + - - - + + + diff --git a/src/NullGC.Abstractions/RefDelegates.cs b/src/NullGC.Abstractions/RefDelegates.cs index 3fa8d4e..09a69cb 100644 --- a/src/NullGC.Abstractions/RefDelegates.cs +++ b/src/NullGC.Abstractions/RefDelegates.cs @@ -1,4 +1,5 @@ -namespace NullGC; +#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type +namespace NullGC; public delegate TR FuncT1RefReadOnly(ref readonly T1 t1, T2 t2); diff --git a/src/NullGC.Allocators/DefaultAllocatorContextImpl.cs b/src/NullGC.Allocators/DefaultAllocatorContextImpl.cs index a9139c2..633408f 100644 --- a/src/NullGC.Allocators/DefaultAllocatorContextImpl.cs +++ b/src/NullGC.Allocators/DefaultAllocatorContextImpl.cs @@ -143,7 +143,7 @@ internal ref readonly PerProviderContainer GetPerProviderContainer(int providerI if (Unsafe.IsNullRef(in ret)) ThrowHelper.ThrowInvalidOperationException($"Provider with ID '{providerId}' is not found."); - return ref ret; + return ref ret!; } private ContextContainer? RentContext() diff --git a/src/NullGC.Collections/NullGC.Collections.csproj b/src/NullGC.Collections/NullGC.Collections.csproj index dd11df5..0d7b75e 100644 --- a/src/NullGC.Collections/NullGC.Collections.csproj +++ b/src/NullGC.Collections/NullGC.Collections.csproj @@ -18,10 +18,10 @@ - + - - - + + + diff --git a/src/NullGC.Collections/ThrowHelper.cs b/src/NullGC.Collections/ThrowHelper.cs index cffa424..85e765d 100644 --- a/src/NullGC.Collections/ThrowHelper.cs +++ b/src/NullGC.Collections/ThrowHelper.cs @@ -26,6 +26,7 @@ public static void ThrowArgumentNullException(string paramName) [DoesNotReturn] public static void ThrowArgumentOutOfRange_IndexMustBeLessException() { + // ReSharper disable once NotResolvedInText throw new ArgumentOutOfRangeException("index", "IndexMustBeLessException"); } @@ -57,6 +58,7 @@ public static void ThrowIndexArgumentOutOfRange_NeedNonNegNumException() [DoesNotReturn] public static void ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_IndexMustBeLessOrEqual() { + // ReSharper disable once NotResolvedInText throw new ArgumentOutOfRangeException("ArgumentOutOfRange_IndexMustBeLessOrEqual"); } @@ -71,31 +73,14 @@ public static void ThrowArgumentException_Argument_IncompatibleArrayType() { throw new ArgumentException("Argument_IncompatibleArrayType"); } - - [DoesNotReturn] - public static void ThrowArgumentOutOfRange_IndexMustBeLessOrEqualException() - { - throw new ArgumentOutOfRangeException("IndexMustBeLessOrEqualException"); - } - + [DoesNotReturn] public static void ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count() { + // ReSharper disable once NotResolvedInText throw new ArgumentOutOfRangeException("ArgumentOutOfRange_Count"); } - [DoesNotReturn] - public static void ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_IndexMustBeLess() - { - throw new ArgumentOutOfRangeException("ArgumentOutOfRange_IndexMustBeLess"); - } - - [DoesNotReturn] - public static void ThrowInvalidOperationException_InvalidOperation_EnumOpCantHappen() - { - throw new InvalidOperationException("InvalidOperation_EnumOpCantHappen"); - } - [DoesNotReturn] public static void ThrowKeyNotFoundException(TKey key) where TKey : notnull { @@ -114,18 +99,6 @@ public static void ThrowAddingDuplicateWithKeyArgumentException(TKey key) throw new ArgumentException($"AddingDuplicateWithKey {key}"); } - [DoesNotReturn] - public static void ThrowWrongKeyTypeArgumentException(object? key, Type type) - { - throw new ArgumentException($"WrongKeyType {key} {type}"); - } - - [DoesNotReturn] - public static void ThrowNotSupportedException(string message) - { - throw new NotSupportedException(message); - } - [DoesNotReturn] public static void ThrowNoMoreElements() { diff --git a/src/NullGC.DragRace/Configs.cs b/src/NullGC.DragRace/Configs.cs index a40e095..46a72ad 100644 --- a/src/NullGC.DragRace/Configs.cs +++ b/src/NullGC.DragRace/Configs.cs @@ -26,7 +26,7 @@ internal class InProcConfig : ConfigBase { public InProcConfig() { - AddJob(Job.ShortRun.WithArguments(new[] {new MsBuildArgument("/p:Platform=x64")}) + AddJob(Job.ShortRun//.WithArguments(new[] {new MsBuildArgument("/p:Platform=x64")}) .WithToolchain(InProcessNoEmitToolchain.Instance)) .WithOptions(ConfigOptions.DisableOptimizationsValidator) .AddDiagnoser(new MemoryDiagnoser(new MemoryDiagnoserConfig(true))) @@ -38,7 +38,7 @@ internal class FastConfig : ConfigBase { public FastConfig() { - AddJob(Job.ShortRun.WithArguments(new[] {new MsBuildArgument("/p:Platform=x64")})) + AddJob(Job.ShortRun)//.WithArguments(new[] {new MsBuildArgument("/p:Platform=x64")})) .WithOptions(ConfigOptions.DisableOptimizationsValidator) .AddDiagnoser(new MemoryDiagnoser(new MemoryDiagnoserConfig(true))) .AddLogger(new ConsoleLogger()); @@ -49,7 +49,7 @@ internal class NormalConfig : ConfigBase { public NormalConfig() { - AddJob(Job.MediumRun.WithArguments(new[] {new MsBuildArgument("/p:Platform=x64")})) + AddJob(Job.MediumRun)//.WithArguments(new[] {new MsBuildArgument("/p:Platform=x64")})) .AddDiagnoser(new MemoryDiagnoser(new MemoryDiagnoserConfig(true))) .AddLogger(new ConsoleLogger()); } @@ -59,7 +59,7 @@ internal class CicdConfig : ConfigBase { public CicdConfig() { - AddJob(Job.ShortRun.WithArguments(new[] {new MsBuildArgument("/p:Platform=x64")})) + AddJob(Job.ShortRun)//.WithArguments(new[] {new MsBuildArgument("/p:Platform=x64")})) .AddDiagnoser(new MemoryDiagnoser(new MemoryDiagnoserConfig(true))) .AddExporter(new JsonExporter()).AddExporter(new HtmlExporter()) .AddColumnProvider(DefaultColumnProviders.Instance) @@ -106,6 +106,15 @@ public ConfigBase AddExporter(params IExporter[] newExporters) this.exporters.AddRange(newExporters); return this; } + + public ConfigBase AddHardwareCounters(params HardwareCounter[] newHardwareCounters) + { + foreach (var counter in newHardwareCounters) + { + this.hardwareCounters.Add(counter); + } + return this; + } public IEnumerable GetColumnProviders() { @@ -146,13 +155,13 @@ public IEnumerable GetValidators() yield return (IValidator) ParamsValidator.FailOnError; } - public IOrderer Orderer => null; + public IOrderer? Orderer => null; public ICategoryDiscoverer? CategoryDiscoverer => null; public ConfigUnionRule UnionRule => ConfigUnionRule.Union; - public CultureInfo CultureInfo => null; + public CultureInfo? CultureInfo => null; public ConfigOptions Options { get; set; } = ConfigOptions.Default; diff --git a/src/NullGC.Linq/Enumerators/ArrayLinqRefEnumerator.cs b/src/NullGC.Linq/Enumerators/ArrayLinqRefEnumerator.cs index 0a1055b..3a4c153 100644 --- a/src/NullGC.Linq/Enumerators/ArrayLinqRefEnumerator.cs +++ b/src/NullGC.Linq/Enumerators/ArrayLinqRefEnumerator.cs @@ -50,7 +50,19 @@ public void Reset() } T IEnumerator.Current => Current; - public unsafe T* CurrentPtr => (T*) Unsafe.AsPointer(ref _array[_index]); +#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type + public unsafe T* CurrentPtr +#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type + { + get + { + CommunityToolkit.Diagnostics.ThrowHelper + .ThrowNotSupportedException(); + return default; + //(T*) Unsafe.AsPointer(ref _array[_index]); + } + } + object? IEnumerator.Current => Current; public int? Count => _length; diff --git a/src/NullGC.Linq/Enumerators/Select.cs b/src/NullGC.Linq/Enumerators/Select.cs index a397768..6acdb81 100644 --- a/src/NullGC.Linq/Enumerators/Select.cs +++ b/src/NullGC.Linq/Enumerators/Select.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Runtime.CompilerServices; +#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type namespace NullGC.Linq.Enumerators; diff --git a/src/NullGC.Linq/Enumerators/Skip.cs b/src/NullGC.Linq/Enumerators/Skip.cs index ab7f7dc..d98ba53 100644 --- a/src/NullGC.Linq/Enumerators/Skip.cs +++ b/src/NullGC.Linq/Enumerators/Skip.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Runtime.CompilerServices; +#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type namespace NullGC.Linq.Enumerators; public struct SkipRef : ILinqRefEnumerator, diff --git a/src/NullGC.Linq/Enumerators/Take.cs b/src/NullGC.Linq/Enumerators/Take.cs index 85e00b9..b430bc7 100644 --- a/src/NullGC.Linq/Enumerators/Take.cs +++ b/src/NullGC.Linq/Enumerators/Take.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Runtime.CompilerServices; using CommunityToolkit.Diagnostics; +#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type namespace NullGC.Linq.Enumerators; diff --git a/src/NullGC.Linq/Enumerators/Where.cs b/src/NullGC.Linq/Enumerators/Where.cs index 199b996..6db7b59 100644 --- a/src/NullGC.Linq/Enumerators/Where.cs +++ b/src/NullGC.Linq/Enumerators/Where.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Runtime.CompilerServices; +#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type namespace NullGC.Linq.Enumerators; diff --git a/src/NullGC.Linq/LinqExtensions.First.cs b/src/NullGC.Linq/LinqExtensions.First.cs index da4f2bf..8a638e6 100644 --- a/src/NullGC.Linq/LinqExtensions.First.cs +++ b/src/NullGC.Linq/LinqExtensions.First.cs @@ -15,7 +15,7 @@ public static ref T First(this LinqRefEnumerable { ref var ret = ref FirstOrNullRef(src, predicate); if (Unsafe.IsNullRef(ref ret)) ThrowHelper.SequenceContainsNoElement(); - return ref ret; + return ref ret!; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -59,7 +59,7 @@ public static ref T First(this LinqRefEnumerable(src, predicate, arg); if (Unsafe.IsNullRef(ref ret)) ThrowHelper.SequenceContainsNoElement(); - return ref ret; + return ref ret!; } [MethodImpl(MethodImplOptions.AggressiveInlining)]