Skip to content

Commit

Permalink
Remove #nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinAtanasov committed Apr 14, 2024
1 parent 69e51be commit e1a059c
Show file tree
Hide file tree
Showing 26 changed files with 123 additions and 141 deletions.
2 changes: 0 additions & 2 deletions Applications/AppBrix.WebApp/Data/BooksDbContext.cs
Expand Up @@ -5,9 +5,7 @@ namespace AppBrix.WebApp.Data;

public class BooksDbContext : DbContextBase
{
#nullable disable
public DbSet<Book> Books { get; set; }
#nullable restore

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
Expand Down
6 changes: 2 additions & 4 deletions Applications/AppBrix.WebApp/Services/BooksService.cs
Expand Up @@ -17,7 +17,7 @@ public void Initialize(IInitializeContext context)

public void Uninitialize()
{
this.app = null;
this.app = null!;
}

public IEnumerable<Book> Get()
Expand Down Expand Up @@ -64,8 +64,6 @@ public void Delete(Guid id)
#endregion

#region Private fields and constants
#nullable disable
private IApp app;
#nullable restore
private IApp app = null!;
#endregion
}
4 changes: 1 addition & 3 deletions Core/AppBrix/Application/DefaultApp.cs
Expand Up @@ -20,14 +20,12 @@ public DefaultApp(IConfigService configService)
throw new ArgumentNullException(nameof(configService));

this.ConfigService = configService;
this.Container = null;
this.Container = null!;
}
#endregion

#region Properties
#nullable disable
public IContainer Container { get; set; }
#nullable restore

public IConfigService ConfigService { get; }

Expand Down
12 changes: 5 additions & 7 deletions Core/AppBrix/Modules/ModuleBase.cs
Expand Up @@ -15,12 +15,10 @@ namespace AppBrix.Modules;
public abstract class ModuleBase : IModule
{
#region Properties
#nullable disable
/// <summary>
/// Gets the current module's app.
/// </summary>
protected IApp App { get; private set; }
#nullable restore
protected IApp App { get; private set; } = null!;

/// <summary>
/// Gets the types of the modules which are direct dependencies for the current module.
Expand All @@ -38,21 +36,21 @@ void IInstallable.Configure(IConfigureContext context)
{
this.App = context.App;
this.Configure(context);
this.App = null;
this.App = null!;
}

void IInstallable.Install(IInstallContext context)
{
this.App = context.App;
this.Install(context);
this.App = null;
this.App = null!;
}

void IInstallable.Uninstall(IUninstallContext context)
{
this.App = context.App;
this.Uninstall(context);
this.App = null;
this.App = null!;
}

void IApplicationLifecycle.Initialize(IInitializeContext context)
Expand All @@ -64,7 +62,7 @@ void IApplicationLifecycle.Initialize(IInitializeContext context)
void IApplicationLifecycle.Uninitialize()
{
this.Uninitialize();
this.App = null;
this.App = null!;
}
#endregion

Expand Down
14 changes: 6 additions & 8 deletions Modules/AppBrix.Caching.Memory/Impl/MemoryCache.cs
Expand Up @@ -29,7 +29,7 @@ public void Uninitialize()
if (this.cleanupScheduledEventArgs is not null)
{
this.app.GetTimerScheduledEventHub().Unschedule(this.cleanupScheduledEventArgs);
this.cleanupScheduledEventArgs = null;
this.cleanupScheduledEventArgs = null!;
}
}

Expand All @@ -39,8 +39,8 @@ public void Uninitialize()

this.keysToRemove.AddRange(this.cache.Keys);
this.RemoveItemsByKeys();
this.config = null;
this.app = null;
this.config = null!;
this.app = null!;
}
}
#endregion
Expand Down Expand Up @@ -154,10 +154,8 @@ private void RemoveItemsByKeys()
private readonly Dictionary<object, CacheItem> cache = new Dictionary<object, CacheItem>();
private readonly List<object> keysToRemove = new List<object>();
private readonly MemoryCacheCleanup cleanupEventArgs = new MemoryCacheCleanup();
#nullable disable
private IApp app;
private IScheduledEvent<MemoryCacheCleanup> cleanupScheduledEventArgs;
private MemoryCachingConfig config;
#nullable restore
private IApp app = null!;
private IScheduledEvent<MemoryCacheCleanup> cleanupScheduledEventArgs = null!;
private MemoryCachingConfig config = null!;
#endregion
}
6 changes: 2 additions & 4 deletions Modules/AppBrix.Caching/Impl/Cache.cs
Expand Up @@ -20,7 +20,7 @@ public void Initialize(IInitializeContext context)

public void Uninitialize()
{
this.app = null;
this.app = null!;
}
#endregion

Expand All @@ -39,8 +39,6 @@ public void Uninitialize()
#endregion

#region Private fields and constants
#nullable disable
private IApp app;
#nullable restore
private IApp app = null!;
#endregion
}
4 changes: 1 addition & 3 deletions Modules/AppBrix.Caching/Services/ICache.cs
Expand Up @@ -20,16 +20,14 @@ public interface ICache
/// <returns></returns>
Task Refresh(string key, CancellationToken token = default);

#nullable disable
/// <summary>
/// Gets a cached object by its key.
/// </summary>
/// <typeparam name="T">The type of the object to get.</typeparam>
/// <param name="key">The key which is used to store the object in the cache.</param>
/// <param name="token">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns></returns>
async Task<T> Get<T>(string key, CancellationToken token = default) => (T)(await this.Get(key, typeof(T), token).ConfigureAwait(false) ?? default(T));
#nullable restore
async Task<T> Get<T>(string key, CancellationToken token = default) => (T)(await this.Get(key, typeof(T), token).ConfigureAwait(false) ?? default(T))!;

/// <summary>
/// Gets a cached object by its key.
Expand Down
2 changes: 0 additions & 2 deletions Modules/AppBrix.Data.Migrations/Data/MigrationsDbContext.cs
Expand Up @@ -11,7 +11,6 @@ namespace AppBrix.Data.Migrations.Data;
/// </summary>
public sealed class MigrationsDbContext : DbContextBase
{
#nullable disable
/// <summary>
/// Gets or sets the database migration data.
/// </summary>
Expand All @@ -21,7 +20,6 @@ public sealed class MigrationsDbContext : DbContextBase
/// Gets or sets the database migration snapshots.
/// </summary>
public DbSet<SnapshotData> Snapshots { get; set; }
#nullable restore

/// <summary>
/// Configures the creation of the database migration models.
Expand Down
18 changes: 8 additions & 10 deletions Modules/AppBrix.Data.Migrations/Impl/MigrationsDbContextService.cs
Expand Up @@ -43,10 +43,10 @@ public void Initialize(IInitializeContext context)

public void Uninitialize()
{
this.app = null;
this.config = null;
this.contextService = null;
this.loggingConfig = null;
this.app = null!;
this.config = null!;
this.contextService = null!;
this.loggingConfig = null!;
this.initializedContexts.Clear();
}

Expand Down Expand Up @@ -310,11 +310,9 @@ private string GenerateMigrationsHistoryTableName(Type type)
#region Private fields and constants
private const string EmptyVersion = "0.0.0.0";
private readonly HashSet<Type> initializedContexts = new HashSet<Type>();
#nullable disable
private IApp app;
private MigrationsDataConfig config;
private IDbContextService contextService;
private LoggingConfig loggingConfig;
#nullable restore
private IApp app = null!;
private MigrationsDataConfig config = null!;
private IDbContextService contextService = null!;
private LoggingConfig loggingConfig = null!;
#endregion
}
6 changes: 2 additions & 4 deletions Modules/AppBrix.Data/Data/DbContextBase.cs
Expand Up @@ -15,12 +15,10 @@ namespace AppBrix.Data.Data;
public abstract class DbContextBase : DbContext
{
#region Properties
#nullable disable
/// <summary>
/// Gets the current <see cref="IApp"/>.
/// </summary>
protected IApp App { get; private set; }
#nullable restore
protected IApp App { get; private set; } = null!;

/// <summary>
/// Gets the migrations assembly to be used during migrations.
Expand Down Expand Up @@ -53,7 +51,7 @@ public void Initialize(IInitializeDbContext context)
public override void Dispose()
{
base.Dispose();
this.App = null;
this.App = null!;
this.MigrationsAssembly = null;
this.MigrationsHistoryTable = null;
GC.SuppressFinalize(this);
Expand Down
6 changes: 2 additions & 4 deletions Modules/AppBrix.Data/Impl/DbContextService.cs
Expand Up @@ -19,7 +19,7 @@ public void Initialize(IInitializeContext context)

public void Uninitialize()
{
this.app = null;
this.app = null!;
}

public DbContext Get(Type type)
Expand All @@ -35,8 +35,6 @@ public DbContext Get(Type type)
#endregion

#region Private fields and constants
#nullable disable
private IApp app;
#nullable restore
private IApp app = null!;
#endregion
}
6 changes: 2 additions & 4 deletions Modules/AppBrix.Events.Async/Impl/AsyncEventHub.cs
Expand Up @@ -22,7 +22,7 @@ public void Initialize(IInitializeContext context)
public void Uninitialize()
{
this.taskQueues.Keys.ToList().ForEach(this.RemoveTaskQueue);
this.app = null;
this.app = null!;
}
#endregion

Expand Down Expand Up @@ -114,8 +114,6 @@ private void RemoveTaskQueue(Type type)
#region Private fields and constants
private readonly Dictionary<Type, ITaskQueue> taskQueues = new Dictionary<Type, ITaskQueue>();
private readonly Dictionary<Type, Action> taskQueueUnsubscribers = new Dictionary<Type, Action>();
#nullable disable
private IApp app;
#nullable restore
private IApp app = null!;
#endregion
}
21 changes: 8 additions & 13 deletions Modules/AppBrix.Events.Delayed/Impl/DelayedEventHub.cs
Expand Up @@ -14,9 +14,7 @@ namespace AppBrix.Events.Delayed.Impl;
internal sealed class DelayedEventHub : IDelayedEventHub, IApplicationLifecycle
{
#region Properties
#nullable disable
public IEventHub EventHub { get; private set; }
#nullable restore
public IEventHub EventHub { get; private set; } = null!;
#endregion

#region IApplicationLifecycle implementation
Expand All @@ -41,10 +39,10 @@ public void Uninitialize()
this.Flush();
}

this.EventHub = null;
this.config = null;
this.channel = null;
this.app = null;
this.EventHub = null!;
this.config = null!;
this.channel = null!;
this.app = null!;
}
#endregion

Expand Down Expand Up @@ -110,14 +108,11 @@ public void RaiseImmediate(IEvent args)

this.EventHub.Raise(args);
}

#endregion

#region Private fields and constants
#nullable disable
private IApp app;
private Channel<IEvent> channel;
private DelayedEventsConfig config;
#nullable restore
private IApp app = null!;
private Channel<IEvent> channel = null!;
private DelayedEventsConfig config = null!;
#endregion
}
Expand Up @@ -19,7 +19,7 @@ public void Initialize(IInitializeContext context)

public void Uninitialize()
{
this.app = null;
this.app = null!;
}
#endregion

Expand All @@ -46,8 +46,6 @@ public void Uninitialize()
#endregion

#region Private fields and constants
#nullable disable
private IApp app;
#nullable restore
private IApp app = null!;
#endregion
}
Expand Up @@ -19,7 +19,7 @@ public void Initialize(IInitializeContext context)

public void Uninitialize()
{
this.app = null;
this.app = null!;
}
#endregion

Expand Down Expand Up @@ -54,8 +54,6 @@ public void Uninitialize()
#endregion

#region Private fields and constants
#nullable disable
private IApp app;
#nullable restore
private IApp app = null!;
#endregion
}
12 changes: 5 additions & 7 deletions Modules/AppBrix.Events.Schedule/Impl/ScheduledEventHub.cs
Expand Up @@ -39,8 +39,8 @@ public void Uninitialize()
}

this.app.GetAsyncEventHub().Unsubscribe<PriorityQueueItem>(this.PriorityQueueItemRaised);
this.config = null;
this.app = null;
this.config = null!;
this.app = null!;
}
#endregion

Expand Down Expand Up @@ -110,10 +110,8 @@ private async Task Run(CancellationToken token)
private readonly PriorityQueue queue = new PriorityQueue();
private readonly List<PriorityQueueItem> executing = new List<PriorityQueueItem>();
private CancellationTokenSource? cts;
#nullable disable
private IApp app;
private ScheduledEventsConfig config;
private PeriodicTimer timer;
#nullable restore
private IApp app = null!;
private ScheduledEventsConfig config = null!;
private PeriodicTimer timer = null!;
#endregion
}

0 comments on commit e1a059c

Please sign in to comment.