From b64fc5d2bc0daff7ff30cdf33dd267e4b53aedcf Mon Sep 17 00:00:00 2001 From: Fryderyk Huang Date: Tue, 30 Jan 2024 22:14:13 +0800 Subject: [PATCH] CodeFix project: generate comment instead of opening browser; Vsix: Auto version number; Update dependencies. --- .../Linq/LinqFixedRefEnumerable.cs | 5 +++-- .../AllocatorContextInitializer.cs | 4 ++-- src/NullGC.TestCommons/AssertEx.cs | 4 ++-- src/NullGC.TestCommons/AssertMemoryAllFreedBase.cs | 12 ++++++------ src/NullGC.TestCommons/TestBase.cs | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/NullGC.Abstractions/Linq/LinqFixedRefEnumerable.cs b/src/NullGC.Abstractions/Linq/LinqFixedRefEnumerable.cs index 8c5adf4..f56de44 100644 --- a/src/NullGC.Abstractions/Linq/LinqFixedRefEnumerable.cs +++ b/src/NullGC.Abstractions/Linq/LinqFixedRefEnumerable.cs @@ -16,7 +16,7 @@ public LinqFixedRefEnumerable(TEnumerator enumerator) IEnumerator IEnumerable.GetEnumerator() { - throw new NotImplementedException(); + return _enumerator; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -29,10 +29,11 @@ public TEnumerator GetEnumerator() // { // return new EnumerableWrapper(_enumerator); // } - + public int? Count => _enumerator.Count; public int? MaxCount => _enumerator.Count; + IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); diff --git a/src/NullGC.TestCommons/AllocatorContextInitializer.cs b/src/NullGC.TestCommons/AllocatorContextInitializer.cs index 9c5848b..9046976 100644 --- a/src/NullGC.TestCommons/AllocatorContextInitializer.cs +++ b/src/NullGC.TestCommons/AllocatorContextInitializer.cs @@ -23,8 +23,8 @@ public static void SetupDefaultUnscopedAllocationContext(out IMemoryAllocationTr allocTracker = nativeTracker = nt; } - public static void SetupDefaultUncachedUnscopedAllocationContext(out IMemoryAllocationTrackable allocTracker, - out IMemoryAllocationTrackable nativeTracker) + public static void SetupDefaultUncachedUnscopedAllocationContext(out IMemoryAllocationTrackable? allocTracker, + out IMemoryAllocationTrackable? nativeTracker) { var nt = new DefaultAlignedNativeMemoryAllocator(); AllocatorContext.SetAllocatorProvider(nt, (int) AllocatorTypes.Default, false); diff --git a/src/NullGC.TestCommons/AssertEx.cs b/src/NullGC.TestCommons/AssertEx.cs index 4b876ba..be720c6 100644 --- a/src/NullGC.TestCommons/AssertEx.cs +++ b/src/NullGC.TestCommons/AssertEx.cs @@ -10,10 +10,10 @@ private static Exception Throws(Type exceptionType, Exception? exception) Guard.IsNotNull(exceptionType); if (exception == null) - throw new ThrowsException(exceptionType); + throw ThrowsException.ForNoException(exceptionType); if (exceptionType != exception.GetType()) - throw new ThrowsException(exceptionType, exception); + throw ThrowsException.ForIncorrectExceptionType(exceptionType, exception); return exception; } diff --git a/src/NullGC.TestCommons/AssertMemoryAllFreedBase.cs b/src/NullGC.TestCommons/AssertMemoryAllFreedBase.cs index cc1e4f8..7479779 100644 --- a/src/NullGC.TestCommons/AssertMemoryAllFreedBase.cs +++ b/src/NullGC.TestCommons/AssertMemoryAllFreedBase.cs @@ -9,10 +9,10 @@ namespace NullGC.TestCommons; public abstract class AssertMemoryAllFreedBase : TestBase, IDisposable, IClassFixture { private readonly bool _scoped; - private readonly IMemoryAllocationTrackable _memTrackable; - private readonly IMemoryAllocationTrackable _allocTrackable; + private readonly IMemoryAllocationTrackable? _memTrackable; + private readonly IMemoryAllocationTrackable? _allocTrackable; - protected IMemoryAllocationTrackable AllocTracker => _allocTrackable; + protected IMemoryAllocationTrackable? AllocTracker => _allocTrackable; protected AssertMemoryAllFreedBase(ITestOutputHelper logger, bool scoped, bool uncached = false) : base(logger) { @@ -28,14 +28,14 @@ protected AssertMemoryAllFreedBase(ITestOutputHelper logger, bool scoped, bool u out _memTrackable); } - public virtual void Dispose() + public override void Dispose() { if (_allocTrackable is IAllocatorCacheable c1) c1.ClearCachedMemory(); if (_allocTrackable is not null) Assert.True(_allocTrackable.ClientIsAllFreed); if (_allocTrackable is IAllocatorCacheable c2) c2.ClearCachedMemory(); - if (_scoped) - Assert.True(_memTrackable.IsAllFreed); + if (_scoped) + if (_memTrackable is not null) Assert.True(_memTrackable.IsAllFreed); AllocatorContext.ClearProvidersAndAllocations(); } } \ No newline at end of file diff --git a/src/NullGC.TestCommons/TestBase.cs b/src/NullGC.TestCommons/TestBase.cs index 82f07f5..a83b451 100644 --- a/src/NullGC.TestCommons/TestBase.cs +++ b/src/NullGC.TestCommons/TestBase.cs @@ -14,7 +14,7 @@ protected TestBase(ITestOutputHelper logger) else throw new InvalidOperationException(); } - public void Dispose() + public virtual void Dispose() { if (_logger.TryGetITest(out var test)) _logger.WriteLine($"Finished test '{test.DisplayName}'"); else throw new InvalidOperationException();