1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-05 01:52:49 -05:00

Tools - Make Entities and Repositories nullable (#3313)

* support nullability in tools' entities and repositories

* enables C# nullability checks in these files
* includes documentation for affected files

* refine documentation per code review

* improve comments on SendFileData structure

* fix ReferenceEvent.MaxAccessCount documentation

* add value notation to SendFileData.FileName
This commit is contained in:
✨ Audrey ✨
2023-11-22 15:44:25 -05:00
committed by GitHub
parent 8e5598a1dd
commit 98c12d3f41
9 changed files with 447 additions and 29 deletions

View File

@ -1,4 +1,6 @@
using AutoMapper;
#nullable enable
using AutoMapper;
using Bit.Core.Tools.Repositories;
using Bit.Infrastructure.EntityFramework.Models;
using Bit.Infrastructure.EntityFramework.Repositories;
@ -7,12 +9,28 @@ using Microsoft.Extensions.DependencyInjection;
namespace Bit.Infrastructure.EntityFramework.Tools.Repositories;
/// <inheritdoc cref="ISendRepository"/>
public class SendRepository : Repository<Core.Tools.Entities.Send, Send, Guid>, ISendRepository
{
/// <summary>
/// Initializes the <see cref="SendRepository"/>
/// </summary>
/// <param name="serviceScopeFactory">An IoC service locator.</param>
/// <param name="mapper">An automapper service.</param>
public SendRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
: base(serviceScopeFactory, mapper, (DatabaseContext context) => context.Sends)
{ }
/// <summary>
/// Saves a <see cref="Send"/> in the database.
/// </summary>
/// <param name="send">
/// The send being saved.
/// </param>
/// <returns>
/// A task that completes once the save is complete.
/// The task result contains the saved <see cref="Send"/>.
/// </returns>
public override async Task<Core.Tools.Entities.Send> CreateAsync(Core.Tools.Entities.Send send)
{
send = await base.CreateAsync(send);
@ -30,6 +48,7 @@ public class SendRepository : Repository<Core.Tools.Entities.Send, Send, Guid>,
return send;
}
/// <inheritdoc />
public async Task<ICollection<Core.Tools.Entities.Send>> GetManyByDeletionDateAsync(DateTime deletionDateBefore)
{
using (var scope = ServiceScopeFactory.CreateScope())
@ -40,6 +59,7 @@ public class SendRepository : Repository<Core.Tools.Entities.Send, Send, Guid>,
}
}
/// <inheritdoc />
public async Task<ICollection<Core.Tools.Entities.Send>> GetManyByUserIdAsync(Guid userId)
{
using (var scope = ServiceScopeFactory.CreateScope())