diff --git a/Directory.Build.targets b/Directory.Build.targets index ddff399d..861d0313 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -2,7 +2,7 @@ - CS0618;CA1034;CA2201;CA1051;CA1040;CA1724; + CS0618;CA1034;CA2201;CA1051;CA1040;CA1724;CA1065; IDE0044;IDE0130;CA1508; CA5394;CA2007;CA1852;CA1819;CA1711;CA1063;CA1816;CA2234;CS8618;CA1054;CA1810;CA2208;CA1019;CA1831; diff --git a/src/Speckle.Sdk/Serialisation/V2/Receive/DeserializeProcess.cs b/src/Speckle.Sdk/Serialisation/V2/Receive/DeserializeProcess.cs index 3d3cefad..b0e65a7c 100644 --- a/src/Speckle.Sdk/Serialisation/V2/Receive/DeserializeProcess.cs +++ b/src/Speckle.Sdk/Serialisation/V2/Receive/DeserializeProcess.cs @@ -14,8 +14,7 @@ public record DeserializeProcessOptions( bool ThrowOnMissingReferences = true, bool SkipInvalidConverts = false, int? MaxParallelism = null, - bool SkipServer = false, - string? AttributeMask = null + bool SkipServer = false ); public partial interface IDeserializeProcess : IAsyncDisposable; @@ -45,7 +44,6 @@ public sealed class DeserializeProcess( new ObjectLoader( sqLiteJsonCacheManager, serverObjectManager, - options?.AttributeMask, progress, loggerFactory.CreateLogger(), cancellationToken diff --git a/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectLoader.cs b/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectLoader.cs index c3e37fa2..c58ef95d 100644 --- a/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectLoader.cs +++ b/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectLoader.cs @@ -16,13 +16,10 @@ public partial interface IObjectLoader : IDisposable; public sealed class ObjectLoader( ISqLiteJsonCacheManager sqLiteJsonCacheManager, IServerObjectManager serverObjectManager, - string? attributeMask, IProgress? progress, ILogger logger, CancellationToken cancellationToken -#pragma warning disable CS9107 // Parameter is captured into the state of the enclosing type and its value is also passed to the base constructor. The value might be captured by the base class as well. ) : ChannelLoader(cancellationToken), IObjectLoader -#pragma warning restore CS9107 // Parameter is captured into the state of the enclosing type and its value is also passed to the base constructor. The value might be captured by the base class as well. { private int? _allChildrenCount; private long _checkCache; @@ -30,6 +27,7 @@ public sealed class ObjectLoader( private long _downloaded; private long _totalToDownload; private DeserializeProcessOptions _options = new(); + private readonly CancellationToken _cancellationToken = cancellationToken; [AutoInterfaceIgnore] public void Dispose() => sqLiteJsonCacheManager.Dispose(); @@ -47,7 +45,7 @@ public sealed class ObjectLoader( { //assume everything exists as the root is there. var allChildren = ClosureParser - .GetClosuresSorted(rootJson, cancellationToken) + .GetClosuresSorted(rootJson, _cancellationToken) .Select(x => new Id(x.Item1)) .ToList(); //this probably yields away from the Main thread to let host apps update progress @@ -60,11 +58,11 @@ public sealed class ObjectLoader( if (!options.SkipServer) { rootJson = await serverObjectManager - .DownloadSingleObject(rootId, progress, cancellationToken) + .DownloadSingleObject(rootId, progress, _cancellationToken) .NotNull() .ConfigureAwait(false); IReadOnlyCollection allChildrenIds = ClosureParser - .GetClosures(rootJson, cancellationToken) + .GetClosures(rootJson, _cancellationToken) .OrderByDescending(x => x.Item2) .Select(x => new Id(x.Item1)) .Where(x => !x.Value.StartsWith("blob", StringComparison.Ordinal)) @@ -112,13 +110,13 @@ public sealed class ObjectLoader( await foreach ( var (id, json) in serverObjectManager.DownloadObjects( ids.Select(x => x.NotNull()).ToList(), - attributeMask, + null, //TODO: Implement attribute masking in a safe way that will not poison SQLite DB. progress, - cancellationToken + _cancellationToken ) ) { - cancellationToken.ThrowIfCancellationRequested(); + _cancellationToken.ThrowIfCancellationRequested(); Interlocked.Increment(ref _downloaded); progress?.Report(new(ProgressEvent.DownloadObjects, _downloaded, _totalToDownload)); toCache.Add(new(new(id), new(json), true, null)); @@ -140,7 +138,7 @@ public sealed class ObjectLoader( { if (!_options.SkipCache) { - cancellationToken.ThrowIfCancellationRequested(); + _cancellationToken.ThrowIfCancellationRequested(); sqLiteJsonCacheManager.SaveObjects(batch.Select(x => (x.Id.Value, x.Json.Value))); Interlocked.Exchange(ref _cached, _cached + batch.Count); progress?.Report(new(ProgressEvent.CachedToLocal, _cached, _allChildrenCount)); @@ -170,7 +168,7 @@ public sealed class ObjectLoader( private void ThrowIfFailed() { //always check for cancellation first - cancellationToken.ThrowIfCancellationRequested(); + _cancellationToken.ThrowIfCancellationRequested(); if (Exception is not null) { throw new SpeckleException($"Error while loading: {Exception.Message}", Exception); diff --git a/tests/Speckle.Sdk.Serialization.Tests/ExceptionTests.cs b/tests/Speckle.Sdk.Serialization.Tests/ExceptionTests.cs index 7f73bf60..bc71c3d2 100644 --- a/tests/Speckle.Sdk.Serialization.Tests/ExceptionTests.cs +++ b/tests/Speckle.Sdk.Serialization.Tests/ExceptionTests.cs @@ -112,16 +112,15 @@ public class ExceptionTests new DummySqLiteReceiveManager(new Dictionary()), new ExceptionServerObjectManager(), null, - null, new NullLogger(), - default + CancellationToken.None ); await using var process = new DeserializeProcess( o, null, new BaseDeserializer(new ObjectDeserializerFactory()), new NullLoggerFactory(), - default, + CancellationToken.None, new(SkipCache: true, MaxParallelism: 1, SkipServer: true) ); @@ -145,7 +144,7 @@ public class ExceptionTests null, new BaseDeserializer(new ObjectDeserializerFactory()), new NullLoggerFactory(), - default, + CancellationToken.None, new(true, MaxParallelism: 1) ); @@ -170,7 +169,7 @@ public class ExceptionTests null, new BaseDeserializer(new ObjectDeserializerFactory()), new NullLoggerFactory(), - default, + CancellationToken.None, new(MaxParallelism: 1) ); @@ -195,9 +194,7 @@ public class ExceptionTests [SpeckleType("Objects.Geometry.BadBase")] public class BadBase : Base { -#pragma warning disable CA1065 public string BadProp => throw new NotImplementedException(); -#pragma warning restore CA1065 } [Fact] diff --git a/tests/Speckle.Sdk.Serialization.Tests/SerializationTests.cs b/tests/Speckle.Sdk.Serialization.Tests/SerializationTests.cs index 82bc9bee..e7f5f0e7 100644 --- a/tests/Speckle.Sdk.Serialization.Tests/SerializationTests.cs +++ b/tests/Speckle.Sdk.Serialization.Tests/SerializationTests.cs @@ -202,9 +202,8 @@ public class SerializationTests new DummySqLiteReceiveManager(closures), new DummyReceiveServerObjectManager(closures), null, - null, new NullLogger(), - default + CancellationToken.None ) ) {