Skip to content

Commit d775fe7

Browse files
committed
#35568 Zero warnings
1 parent 073f7af commit d775fe7

File tree

27 files changed

+178
-261
lines changed

27 files changed

+178
-261
lines changed

Diff for: .config/dotnet-tools.json

-12
This file was deleted.

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ launchSettings.json
4444
*.Import.props
4545
*.g.props
4646
*.log
47-
/.tools/
47+
/.tools/
48+
/.config/dotnet-tools.json

Diff for: eng/src/BuildMetalamaPatterns.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<LangVersion>latest</LangVersion>
99
<Nullable>enable</Nullable>
10-
<NoWarn>SA0001;CS8002</NoWarn>
10+
<NoWarn>SA0001;CS8002;NU1903;NU1904</NoWarn>
1111
</PropertyGroup>
1212

1313
<ItemGroup>

Diff for: src/Flashtrace.Formatters/TypeExtensions/TypeExtensionInfo.cs

+17-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Flashtrace.Formatters.TypeExtensions;
44

5-
public readonly struct TypeExtensionInfo<T>
5+
public readonly struct TypeExtensionInfo<T> : IEquatable<TypeExtensionInfo<T>>
66
where T : class
77
{
88
internal TypeExtensionInfo( T? extension, Type objectType, bool isGeneric )
@@ -22,4 +22,20 @@ internal TypeExtensionInfo( T? extension, Type objectType, bool isGeneric )
2222

2323
internal bool ShouldOverwrite( TypeExtensionInfo<T> typeExtension )
2424
=> CovariantTypeExtensionFactory<T>.ShouldOverwrite( this.ObjectType, this.IsGeneric, typeExtension.ObjectType, this.IsGeneric );
25+
26+
public bool Equals( TypeExtensionInfo<T> other ) => EqualityComparer<T?>.Default.Equals( this.Extension, other.Extension ) && this.ObjectType == other.ObjectType && this.IsGeneric == other.IsGeneric;
27+
28+
public override bool Equals( object? obj ) => obj is TypeExtensionInfo<T> other && this.Equals( other );
29+
30+
public override int GetHashCode()
31+
{
32+
unchecked
33+
{
34+
var hashCode = this.Extension == null ? 0 : EqualityComparer<T>.Default.GetHashCode( this.Extension );
35+
hashCode = (hashCode * 397) ^ this.ObjectType.GetHashCode();
36+
hashCode = (hashCode * 397) ^ this.IsGeneric.GetHashCode();
37+
38+
return hashCode;
39+
}
40+
}
2541
}

Diff for: src/Metalama.Patterns.Caching.Aspects/InvalidateCacheAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ private static bool ValidateAndFindInvalidatedMethods(
360360

361361
// Check that the 'this' parameter is compatible.
362362
if ( !invalidatedMethod.IsStatic && !cacheAspectConfiguration.IgnoreThisParameter.GetValueOrDefault() &&
363-
(invalidatingMethod.IsStatic || !(invalidatingMethod.DeclaringType == invalidatedMethod.DeclaringType
363+
(invalidatingMethod.IsStatic || !(invalidatingMethod.DeclaringType.Equals( invalidatedMethod.DeclaringType )
364364
|| invalidatingMethod.DeclaringType.DerivesFrom( invalidatedMethod.DeclaringType ))) )
365365
{
366366
matchingErrorsDictionary.Add(

Diff for: src/Metalama.Patterns.Caching.Backend/Implementation/CacheItemConfigurationExtensions.cs

-31
This file was deleted.

Diff for: src/Metalama.Patterns.Caching.Backend/Implementation/MaterializedCacheItem.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
22

3+
using JetBrains.Annotations;
34
using Metalama.Patterns.Caching.Backends;
45
using Metalama.Patterns.Caching.Serializers;
56
using System.Collections.Immutable;
@@ -62,6 +63,7 @@ public MaterializedCacheItem( CacheItem cacheItem ) : base( cacheItem.Value, cac
6263
/// <summary>
6364
/// Gets the absolute expiration of the cache item.
6465
/// </summary>
66+
[PublicAPI]
6567
public DateTime? AbsoluteExpiration { get; }
6668

6769
bool? ICacheItemConfiguration.AutoReload => false;

Diff for: src/Metalama.Patterns.Caching.Backends.Redis/DependenciesRedisCachingBackend.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ private void SetItemTransaction( string key, CacheItem item, ITransaction transa
381381
{
382382
itemList = this.Database.ListRange( valueKey, flags: this.Configuration.ReadCommandFlags );
383383

384-
if ( itemList == null || itemList.Length == 0 )
384+
if ( itemList == null! || itemList.Length == 0 )
385385
{
386386
return null;
387387
}
@@ -419,7 +419,7 @@ private void SetItemTransaction( string key, CacheItem item, ITransaction transa
419419
{
420420
itemList = await this.Database.ListRangeAsync( valueKey, flags: this.Configuration.ReadCommandFlags );
421421

422-
if ( itemList == null || itemList.Length == 0 )
422+
if ( itemList == null! || itemList.Length == 0 )
423423
{
424424
return null;
425425
}

Diff for: src/Metalama.Patterns.Caching.Backends.Redis/ExistingRedisConnectionFactory.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Metalama.Patterns.Caching.Backends.Redis;
66

7-
internal class ExistingRedisConnectionFactory( IConnectionMultiplexer connection ) : IRedisConnectionFactory
7+
internal sealed class ExistingRedisConnectionFactory( IConnectionMultiplexer connection ) : IRedisConnectionFactory
88
{
99
public IConnectionMultiplexer GetConnection( IServiceProvider? serviceProvider ) => connection;
1010

Diff for: src/Metalama.Patterns.Caching.Backends.Redis/RedisCacheSynchronizer.cs

+11-22
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ namespace Metalama.Patterns.Caching.Backends.Redis;
1212
/// instances of local caches.
1313
/// </summary>
1414
[PublicAPI]
15-
internal sealed class RedisCacheSynchronizer : CacheSynchronizer
15+
internal sealed class RedisCacheSynchronizer(
16+
CachingBackend underlyingBackend,
17+
RedisCacheSynchronizerConfiguration configuration )
18+
: CacheSynchronizer( underlyingBackend, configuration )
1619
{
17-
private readonly bool _ownsConnection;
18-
private readonly RedisChannel _channel;
19-
private readonly TimeSpan _connectionTimeout;
20+
private readonly bool _ownsConnection = configuration.OwnsConnection;
21+
private readonly RedisChannel _channel = new( configuration.ChannelName, RedisChannel.PatternMode.Literal );
22+
private readonly TimeSpan _connectionTimeout = configuration.ConnectionTimeout;
2023

2124
private IConnectionMultiplexer? _connection;
2225

@@ -27,27 +30,13 @@ internal sealed class RedisCacheSynchronizer : CacheSynchronizer
2730
/// </summary>
2831
private IConnectionMultiplexer Connection => this._connection ?? throw new InvalidOperationException( "The component is not initialized." );
2932

30-
public RedisCacheSynchronizer(
31-
CachingBackend underlyingBackend,
32-
RedisCacheSynchronizerConfiguration configuration ) : base( underlyingBackend, configuration )
33-
{
34-
this._ownsConnection = configuration.OwnsConnection;
35-
this._connectionTimeout = configuration.ConnectionTimeout;
36-
this._channel = new RedisChannel( configuration.ChannelName, RedisChannel.PatternMode.Literal );
37-
}
38-
3933
protected override void InitializeCore()
4034
{
4135
var redisConnectionFactory = ((RedisCacheSynchronizerConfiguration) this.Configuration).ConnectionFactory;
4236

43-
if ( redisConnectionFactory != null )
44-
{
45-
this._connection = redisConnectionFactory.GetConnection( this.ServiceProvider );
46-
}
47-
else
48-
{
49-
this._connection = this.ServiceProvider.GetRequiredService<IConnectionMultiplexer>();
50-
}
37+
this._connection = redisConnectionFactory != null!
38+
? redisConnectionFactory.GetConnection( this.ServiceProvider )
39+
: this.ServiceProvider.GetRequiredService<IConnectionMultiplexer>();
5140

5241
this.NotificationQueueProcessor = RedisNotificationQueueProcessor.Create(
5342
this.ToString(),
@@ -64,7 +53,7 @@ protected override void InitializeCore()
6453
{
6554
var configuration = (RedisCacheSynchronizerConfiguration) this.Configuration;
6655

67-
if ( configuration.ConnectionFactory != null )
56+
if ( configuration.ConnectionFactory != null! )
6857
{
6958
this._connection =
7059
await configuration.ConnectionFactory.GetConnectionAsync(

Diff for: src/Metalama.Patterns.Caching.Backends.Redis/RedisCachingBackend.cs

+3-8
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,9 @@ internal RedisCachingBackend(
9191

9292
protected override void InitializeCore()
9393
{
94-
if ( this.Configuration.ConnectionFactory != null )
95-
{
96-
this._connection = this.Configuration.ConnectionFactory.GetConnection( this.ServiceProvider );
97-
}
98-
else
99-
{
100-
this._connection = this.ServiceProvider.GetRequiredService<IConnectionMultiplexer>();
101-
}
94+
this._connection = this.Configuration.ConnectionFactory != null!
95+
? this.Configuration.ConnectionFactory.GetConnection( this.ServiceProvider )
96+
: this.ServiceProvider.GetRequiredService<IConnectionMultiplexer>();
10297

10398
this._database = this._databaseFactory( this._connection );
10499
this._keyBuilder = new RedisKeyBuilder( this.Database, this.Configuration );

Diff for: src/Metalama.Patterns.Observability/Implementation/ClassicStrategy/ClassicDesignTimeObservabilityStrategyImpl.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ namespace Metalama.Patterns.Observability.Implementation.ClassicStrategy;
1010

1111
internal sealed class ClassicDesignTimeObservabilityStrategyImpl : DesignTimeObservabilityStrategy
1212
{
13-
private readonly IMethod? _baseOnPropertyChangedInvocableMethod;
1413
private readonly IMethod? _baseOnPropertyChangedOverridableMethod;
1514
private readonly IMethod? _baseOnChildPropertyChangedMethod;
1615
private readonly IMethod? _baseOnObservablePropertyChangedMethod;
@@ -24,7 +23,7 @@ public ClassicDesignTimeObservabilityStrategyImpl( IAspectBuilder<INamedType> bu
2423
var target = builder.Target;
2524
var elements = builder.Target.Compilation.Cache.GetOrAdd( _ => new Assets() );
2625

27-
(this._baseOnPropertyChangedInvocableMethod, this._baseOnPropertyChangedOverridableMethod) =
26+
(_, this._baseOnPropertyChangedOverridableMethod) =
2827
ClassicObservabilityStrategyImpl.GetOnPropertyChangedMethods( target );
2928

3029
this._baseOnChildPropertyChangedMethod = ClassicObservabilityStrategyImpl.GetOnChildPropertyChangedMethod( target );

Diff for: src/Metalama.Patterns.Observability/Implementation/ClassicStrategy/ClassicObservabilityStrategyImpl.cs

+6-11
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,9 @@ private bool TryIntroduceOnPropertyChangedMethod()
225225

226226
this._onPropertyChangedOverridableMethod.Value = result.Declaration;
227227

228-
if ( this._baseOnPropertyChangedOverridableMethod == this._baseOnPropertyChangedInvocableMethod )
229-
{
230-
this._onPropertyChangedInvocableMethod.Value = result.Declaration;
231-
}
232-
else
233-
{
234-
this._onPropertyChangedInvocableMethod.Value = this._baseOnPropertyChangedInvocableMethod!;
235-
}
228+
this._onPropertyChangedInvocableMethod.Value = this._baseOnPropertyChangedOverridableMethod == this._baseOnPropertyChangedInvocableMethod
229+
? result.Declaration
230+
: this._baseOnPropertyChangedInvocableMethod!;
236231

237232
// Ensure that all required fields are generated in advance of template execution.
238233
// The node selection logic mirrors that of the template's loops and conditions.
@@ -269,7 +264,7 @@ private bool TryIntroduceOnChildPropertyChangedMethod()
269264
{
270265
var rootPropertyNode = node.Root;
271266

272-
if ( rootPropertyNode.ReferencedFieldOrProperty.DeclaringType == this.CurrentType )
267+
if ( rootPropertyNode.ReferencedFieldOrProperty.DeclaringType.Equals( this.CurrentType ) )
273268
{
274269
return false;
275270
}
@@ -887,8 +882,8 @@ internal static (IMethod? Invocable, IMethod? Overridable) GetOnPropertyChangedM
887882
ReturnType.SpecialType: SpecialType.Void,
888883
Parameters: [{ Type.SpecialType: SpecialType.String }, { } p1, { } p2]
889884
}
890-
&& p1.Type == assets.NullableINotifyPropertyChanged
891-
&& p2.Type == assets.NullableINotifyPropertyChanged );
885+
&& p1.Type.Equals( assets.NullableINotifyPropertyChanged )
886+
&& p2.Type.Equals( assets.NullableINotifyPropertyChanged ) );
892887

893888
/// <summary>
894889
/// Validates the the intrinsic characteristics of the given <see cref="IFieldOrProperty"/>, reporting diagnostics if applicable.

Diff for: src/Metalama.Patterns.Observability/Implementation/ClassicStrategy/ClassicObservableExpression.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public ClassicObservableExpression(
9797
false => InpcBaseHandling.NotApplicable,
9898

9999
true when this.IsRoot =>
100-
fieldOrProperty.DeclaringType == builder.CurrentType
100+
fieldOrProperty.DeclaringType.Equals( builder.CurrentType )
101101
? InpcBaseHandling.NotApplicable
102102
: builder.Context.HasInheritedOnChildPropertyChangedPropertyPath( this.DottedPropertyPath )
103103
? InpcBaseHandling.OnChildPropertyChanged

Diff for: src/Metalama.Patterns.Wpf/CommandAttribute.cs

+6-16
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,9 @@ private void InitializeCommandWithoutParameter(
295295

296296
if ( canExecuteMethod != null || canExecuteProperty != null )
297297
{
298-
if ( canExecuteMethod != null )
299-
{
300-
canExecuteExpression = ExpressionFactory.Parse( canExecuteMethod.Name );
301-
}
302-
else
303-
{
304-
canExecuteExpression = ExpressionFactory.Capture( new Func<bool>( () => (bool) canExecuteProperty!.Value! ) );
305-
}
298+
canExecuteExpression = canExecuteMethod != null
299+
? ExpressionFactory.Parse( canExecuteMethod.Name )
300+
: ExpressionFactory.Capture( new Func<bool>( () => (bool) canExecuteProperty!.Value! ) );
306301
}
307302

308303
// ReSharper disable ConvertToLambdaExpression
@@ -392,14 +387,9 @@ private void InitializeCommandWithParameter<[CompileTime] T>(
392387

393388
if ( canExecuteMethod != null || canExecuteProperty != null )
394389
{
395-
if ( canExecuteMethod != null )
396-
{
397-
canExecuteExpression = ExpressionFactory.Parse( canExecuteMethod.Name );
398-
}
399-
else
400-
{
401-
canExecuteExpression = ExpressionFactory.Capture( new Func<T, bool>( _ => (bool) canExecuteProperty!.Value! ) );
402-
}
390+
canExecuteExpression = canExecuteMethod != null
391+
? ExpressionFactory.Parse( canExecuteMethod.Name )
392+
: ExpressionFactory.Capture( new Func<T, bool>( _ => (bool) canExecuteProperty!.Value! ) );
403393
}
404394

405395
// ReSharper disable ConvertToLambdaExpression

Diff for: src/Metalama.Patterns.Wpf/DelegateCommandExecution.cs

+3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
22

3+
using JetBrains.Annotations;
4+
35
namespace Metalama.Patterns.Wpf;
46

57
/// <summary>
68
/// Represents a distinct execution of an <see cref="AsyncDelegateCommand"/>, exposing its <see cref="Task"/>,
79
/// and allowing to cancel it.
810
/// </summary>
11+
[PublicAPI]
912
public readonly struct DelegateCommandExecution
1013
{
1114
private readonly CancellationTokenSource? _cancellationTokenSource;

Diff for: src/Metalama.Patterns.Wpf/IAsyncCommand.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
22

3+
using JetBrains.Annotations;
34
using System.ComponentModel;
45
using System.Windows.Input;
56

@@ -8,6 +9,7 @@ namespace Metalama.Patterns.Wpf;
89
/// <summary>
910
/// Represents an <see cref="ICommand"/> that is executed asynchronously.
1011
/// </summary>
12+
[PublicAPI]
1113
public interface IAsyncCommand : ICommand, INotifyPropertyChanged
1214
{
1315
/// <summary>

Diff for: src/Metalama.Patterns.Wpf/Implementation/DependencyPropertyAspectBuilder.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ public void Build()
4646
|| this._attribute.ValidateMethod != null;
4747

4848
var namingConventions = hasExplicitNaming
49-
?
50-
[
49+
? [
5150
new ExplicitDependencyPropertyNamingConvention(
5251
this._attribute.RegistrationField,
5352
this._attribute.PropertyChangedMethod,

Diff for: src/Metalama.Patterns.Wpf/Implementation/NamingConvention/NamingConventionOutcome.cs

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
using Metalama.Framework.Aspects;
44

5+
namespace Metalama.Patterns.Wpf.Implementation.NamingConvention;
6+
57
[CompileTime]
68
internal enum NamingConventionOutcome
79
{

Diff for: src/tests/Metalama.Patterns.Caching.TestHelpers/BackgroundTaskSchedulerObserver.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ public int OnTaskEnqueued()
1919
return id;
2020
}
2121

22-
public void OnTaskCompleted( int observedTaskId )
23-
{
24-
this._pendingBackgroundTasks.TryRemove( observedTaskId, out _ );
25-
}
22+
public void OnTaskCompleted( int observedTaskId ) => this._pendingBackgroundTasks.TryRemove( observedTaskId, out _ );
2623

27-
public IEnumerable<StackTrace> PendingTasks => this._pendingBackgroundTasks.Values;
24+
internal IEnumerable<StackTrace> PendingTasks => this._pendingBackgroundTasks.Values;
2825
}

Diff for: src/tests/Metalama.Patterns.Caching.UnitTests/AsyncEnumeratorTests.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66

77
namespace Metalama.Patterns.Caching.Tests;
88

9-
public class AsyncEnumeratorTests : AsyncEnumTestsBase
9+
public sealed class AsyncEnumeratorTests( ITestOutputHelper testOutputHelper ) : AsyncEnumTestsBase( testOutputHelper )
1010
{
11-
public AsyncEnumeratorTests( ITestOutputHelper testOutputHelper ) : base( testOutputHelper ) { }
12-
1311
[Fact]
1412
public void DoesNotBlockOnUnawaitedMethod()
1513
{

0 commit comments

Comments
 (0)