Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler warnings related to nullability in Tokens module #506

Merged
merged 38 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1a34208
refactor: add nullable property group
HunorTotBagi Jan 24, 2024
b9d9c35
refactor: make RootFolder nullable
HunorTotBagi Jan 25, 2024
8f5be22
refactor: make Tokens null!
HunorTotBagi Jan 25, 2024
478617a
refactor: make Id required
HunorTotBagi Jan 25, 2024
1a7aa2a
refactor: make ConverterMappingsHints nullable
HunorTotBagi Jan 25, 2024
bb8e6e7
refactor: make Provider and DbConnectionString null!
HunorTotBagi Jan 25, 2024
d518b2f
refactor: make fields required
HunorTotBagi Jan 25, 2024
a879493
refactor: expression is never null according to nullable reference t…
HunorTotBagi Jan 25, 2024
024c85b
refactor: conditional access qualifier expression is never null acco…
HunorTotBagi Jan 25, 2024
cf954c0
refactor: remove check since BlobStorageOptions never null
HunorTotBagi Jan 25, 2024
95dcb1f
fix: revert last made changes
HunorTotBagi Jan 25, 2024
72d8c5d
Merge remote-tracking branch 'origin/main' into fix-tokens-related-is…
HunorTotBagi Jan 25, 2024
a111a13
refactor: suppress null
HunorTotBagi Jan 25, 2024
9163213
refactor: make field Content required
HunorTotBagi Jan 25, 2024
d0fa25a
Merge remote-tracking branch 'origin/main' into fix-tokens-related-is…
HunorTotBagi Jan 26, 2024
09500bb
refactor: remove expression for checking null
HunorTotBagi Jan 26, 2024
6071a70
refactor: allow BlobStorageOptions to be nullable
HunorTotBagi Jan 26, 2024
b46f65e
refactor: revert BlobStorageOptions to null!
HunorTotBagi Jan 26, 2024
a3604ff
refactor: make IdentityAddress nullable
HunorTotBagi Jan 26, 2024
8c09648
ci: trigger pipelines
HunorTotBagi Jan 26, 2024
55ad943
refactor: allow BlobStorageOptions to be null and initializes a new i…
HunorTotBagi Jan 26, 2024
e32e95e
refactor: revert changes
HunorTotBagi Jan 26, 2024
07dfbb6
refactor: make BlobStorageOptions nullable
HunorTotBagi Jan 26, 2024
eeab0c3
Merge main into fix-tokens-related-issues
github-actions[bot] Jan 29, 2024
67133da
refactor: make ExpresAt required
HunorTotBagi Jan 29, 2024
430fad1
refactor: make CreatedAt required
HunorTotBagi Jan 29, 2024
db5f65f
refactor: make CreatedAt & ExpiresAt required
HunorTotBagi Jan 29, 2024
aa5384f
Merge branch 'fix-tokens-related-issues' of https://github.com/nmshd/…
HunorTotBagi Jan 29, 2024
24dfbb7
Merge main into fix-tokens-related-issues
github-actions[bot] Jan 29, 2024
6ab917f
Merge main into fix-tokens-related-issues
github-actions[bot] Jan 30, 2024
a8af3a9
Merge main into fix-tokens-related-issues
github-actions[bot] Feb 5, 2024
2c8799c
Merge main into fix-tokens-related-issues
github-actions[bot] Feb 5, 2024
0a07d30
Merge main into fix-tokens-related-issues
github-actions[bot] Feb 6, 2024
6f87bc5
Merge main into fix-tokens-related-issues
github-actions[bot] Feb 9, 2024
2dfa44e
Merge main into fix-tokens-related-issues
github-actions[bot] Feb 9, 2024
2b86a8d
Merge main into fix-tokens-related-issues
github-actions[bot] Feb 9, 2024
7fa5fb8
chore: minor changes
tnotheis Feb 9, 2024
0f7f5e8
Merge branch 'fix-tokens-related-issues' of github.com:nmshd/backbone…
tnotheis Feb 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public class BlobOptions
{
public string RootFolder { get; set; }
public string? RootFolder { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.8.1" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ namespace Backbone.Modules.Tokens.Application.Tokens.Commands.CreateToken;
[ApplyQuotasForMetrics("NumberOfTokens")]
public class CreateTokenCommand : IRequest<CreateTokenResponse>, IMapTo<Token>
{
public byte[] Content { get; set; }
public DateTime ExpiresAt { get; set; }
public required byte[] Content { get; set; }
public required DateTime ExpiresAt { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ namespace Backbone.Modules.Tokens.Application.Tokens.Commands.CreateToken;

public class CreateTokenResponse : IMapTo<Token>
{
public TokenId Id { get; set; }
public DateTime CreatedAt { get; set; }
public required TokenId Id { get; set; }
public required DateTime CreatedAt { get; set; }
}
12 changes: 6 additions & 6 deletions Modules/Tokens/src/Tokens.Application/Tokens/DTOs/TokenDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace Backbone.Modules.Tokens.Application.Tokens.DTOs;

public class TokenDTO : IMapTo<Token>
{
public TokenId Id { get; set; }
public required TokenId Id { get; set; }

public IdentityAddress CreatedBy { get; set; }
public DeviceId CreatedByDevice { get; set; }
public required IdentityAddress CreatedBy { get; set; }
public required DeviceId CreatedByDevice { get; set; }

public DateTime CreatedAt { get; set; }
public DateTime ExpiresAt { get; set; }
public required DateTime CreatedAt { get; set; }
public required DateTime ExpiresAt { get; set; }

public byte[] Content { get; set; }
public required byte[] Content { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ namespace Backbone.Modules.Tokens.Application.Tokens.Queries.GetToken;

public class GetTokenQuery : IRequest<TokenDTO>
{
public TokenId Id { get; set; }
public required TokenId Id { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Tokens.Infrastructure\Tokens.Infrastructure.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Tokens.Infrastructure\Tokens.Infrastructure.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Tokens.Infrastructure\Tokens.Infrastructure.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Tokens.Infrastructure\Tokens.Infrastructure.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static class IServiceCollectionExtensions
public static void AddDatabase(this IServiceCollection services, Action<DbOptions> setupOptions)
{
var options = new DbOptions();
setupOptions?.Invoke(options);
setupOptions.Invoke(options);

services.AddDatabase(options);
}
Expand Down Expand Up @@ -53,8 +53,8 @@ public static void AddDatabase(this IServiceCollection services, DbOptions optio

public class DbOptions
{
public string Provider { get; set; }
public string DbConnectionString { get; set; }
public string Provider { get; set; } = null!;
public string DbConnectionString { get; set; } = null!;
public RetryOptions RetryOptions { get; set; } = new();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ namespace Backbone.Modules.Tokens.Infrastructure.Persistence.Database;

public class TokensDbContext : AbstractDbContextBase
{
public TokensDbContext() { }
public TokensDbContext()
{
}

public TokensDbContext(DbContextOptions<TokensDbContext> options) : base(options) { }
public TokensDbContext(DbContextOptions<TokensDbContext> options) : base(options)
{
}

public TokensDbContext(DbContextOptions<TokensDbContext> options, IServiceProvider serviceProvider) : base(options, serviceProvider) { }
public TokensDbContext(DbContextOptions<TokensDbContext> options, IServiceProvider serviceProvider) : base(options, serviceProvider)
{
}

public virtual DbSet<Token> Tokens { get; set; }
public virtual DbSet<Token> Tokens { get; set; } = null!;

//protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
//{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ public class TokenIdEntityFrameworkValueConverter : ValueConverter<TokenId, stri
{
public TokenIdEntityFrameworkValueConverter() : this(null) { }

public TokenIdEntityFrameworkValueConverter(ConverterMappingHints mappingHints)
public TokenIdEntityFrameworkValueConverter(ConverterMappingHints? mappingHints)
: base(
id => id == null ? null : id.StringValue,
id => id.StringValue,
value => TokenId.Parse(value),
mappingHints
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static class IServiceCollectionExtensions
public static void AddPersistence(this IServiceCollection services, Action<PersistenceOptions> setupOptions)
{
var options = new PersistenceOptions();
setupOptions?.Invoke(options);
setupOptions.Invoke(options);

services.AddPersistence(options);
}
Expand All @@ -26,13 +26,12 @@ public static void AddPersistence(this IServiceCollection services, PersistenceO
services.Configure<BlobOptions>(blobOptions => blobOptions.RootFolder = options.BlobStorageOptions.Container);
}


services.AddRepositories();
}
}

public class PersistenceOptions
{
public DbOptions DbOptions { get; set; } = new();
public BlobStorageOptions BlobStorageOptions { get; set; }
public BlobStorageOptions? BlobStorageOptions { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public async Task<Token> Find(TokenId id)

public async Task<DbPaginationResult<Token>> FindAllWithIds(IEnumerable<TokenId> ids, PaginationFilter paginationFilter, CancellationToken cancellationToken)
{
return await Find(null, ids, paginationFilter, cancellationToken);
return await Find(null!, ids, paginationFilter, cancellationToken);
}

public async Task<DbPaginationResult<Token>> FindAllOfOwner(IdentityAddress owner, PaginationFilter paginationFilter, CancellationToken cancellationToken)
{
return await Find(owner, Array.Empty<TokenId>(), paginationFilter, cancellationToken);
}

private async Task<DbPaginationResult<Token>> Find(IdentityAddress owner, IEnumerable<TokenId> ids, PaginationFilter paginationFilter, CancellationToken cancellationToken)
private async Task<DbPaginationResult<Token>> Find(IdentityAddress? owner, IEnumerable<TokenId> ids, PaginationFilter paginationFilter, CancellationToken cancellationToken)
{
if (paginationFilter == null)
throw new Exception("A pagination filter has to be provided.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down