Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update null! usage to required or default empty value (#233)

Leendert de Borst061e72210f43
diff --git a/src/AliasVault.Admin/Auth/Components/InputTextField.razor b/src/AliasVault.Admin/Auth/Components/InputTextField.razor
index d0777464d..a85ed93dd 100644
--- a/src/AliasVault.Admin/Auth/Components/InputTextField.razor
+++ b/src/AliasVault.Admin/Auth/Components/InputTextField.razor
@@ -12,30 +12,36 @@
/// <summary>
/// Gets or sets the ID of the input field.
/// </summary>
- [Parameter] public string Id { get; set; } = null!;
+ [Parameter]
+ public required string Id { get; set; }
/// <summary>
/// Gets or sets the value of the input field.
/// </summary>
- [Parameter] public string Value { get; set; } = null!;
+ [Parameter]
+ public required string Value { get; set; }
/// <summary>
/// Gets or sets the event callback that is triggered when the value changes.
/// </summary>
- [Parameter] public EventCallback<string?> ValueChanged { get; set; }
+ [Parameter]
+ public required EventCallback<string?> ValueChanged { get; set; }
/// <summary>
/// Gets or sets the expression that identifies the value property.
/// </summary>
- [Parameter] public Expression<Func<string>> ValueExpression { get; set; } = null!;
+ [Parameter]
+ public required Expression<Func<string>> ValueExpression { get; set; }
/// <summary>
/// Gets or sets the placeholder text for the input field.
/// </summary>
- [Parameter] public string Placeholder { get; set; } = null!;
+ [Parameter]
+ public required string Placeholder { get; set; }
/// <summary>
/// Gets or sets additional attributes for the input field.
/// </summary>
- [Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object?>? AdditionalAttributes { get; set; } = new();
+ [Parameter(CaptureUnmatchedValues = true)]
+ public Dictionary<string, object?>? AdditionalAttributes { get; set; } = new();
}
diff --git a/src/AliasVault.Client/Auth/Components/InputTextField.razor b/src/AliasVault.Client/Auth/Components/InputTextField.razor
index d0777464d..a85ed93dd 100644
--- a/src/AliasVault.Client/Auth/Components/InputTextField.razor
+++ b/src/AliasVault.Client/Auth/Components/InputTextField.razor
@@ -12,30 +12,36 @@
/// <summary>
/// Gets or sets the ID of the input field.
/// </summary>
- [Parameter] public string Id { get; set; } = null!;
+ [Parameter]
+ public required string Id { get; set; }
/// <summary>
/// Gets or sets the value of the input field.
/// </summary>
- [Parameter] public string Value { get; set; } = null!;
+ [Parameter]
+ public required string Value { get; set; }
/// <summary>
/// Gets or sets the event callback that is triggered when the value changes.
/// </summary>
- [Parameter] public EventCallback<string?> ValueChanged { get; set; }
+ [Parameter]
+ public required EventCallback<string?> ValueChanged { get; set; }
/// <summary>
/// Gets or sets the expression that identifies the value property.
/// </summary>
- [Parameter] public Expression<Func<string>> ValueExpression { get; set; } = null!;
+ [Parameter]
+ public required Expression<Func<string>> ValueExpression { get; set; }
/// <summary>
/// Gets or sets the placeholder text for the input field.
/// </summary>
- [Parameter] public string Placeholder { get; set; } = null!;
+ [Parameter]
+ public required string Placeholder { get; set; }
/// <summary>
/// Gets or sets additional attributes for the input field.
/// </summary>
- [Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object?>? AdditionalAttributes { get; set; } = new();
+ [Parameter(CaptureUnmatchedValues = true)]
+ public Dictionary<string, object?>? AdditionalAttributes { get; set; } = new();
}
diff --git a/src/AliasVault.Client/Main/Components/Credentials/CredentialCard.razor b/src/AliasVault.Client/Main/Components/Credentials/CredentialCard.razor
index 29f1737eb..dc7cfe717 100644
--- a/src/AliasVault.Client/Main/Components/Credentials/CredentialCard.razor
+++ b/src/AliasVault.Client/Main/Components/Credentials/CredentialCard.razor
@@ -14,7 +14,7 @@
/// Gets or sets the credentials object to show.
/// </summary>
[Parameter]
- public CredentialListEntry Obj { get; set; } = null!;
+ public required CredentialListEntry Obj { get; set; }
private void ShowDetails()
{
diff --git a/src/AliasVault.Client/Main/Components/Layout/ClickOutsideHandler.razor b/src/AliasVault.Client/Main/Components/Layout/ClickOutsideHandler.razor
index 9f0b596ad..6a454157b 100644
--- a/src/AliasVault.Client/Main/Components/Layout/ClickOutsideHandler.razor
+++ b/src/AliasVault.Client/Main/Components/Layout/ClickOutsideHandler.razor
@@ -20,10 +20,11 @@
/// The child content of the component.
/// </summary>
[Parameter]
- public RenderFragment ChildContent { get; set; } = null!;
+ public required RenderFragment ChildContent { get; set; }
private DotNetObjectReference<ClickOutsideHandler>? ObjRef { get; set; }
- private IJSObjectReference? Module { get; set; } = null!;
+
+ private IJSObjectReference? Module { get; set; }
/// <inheritdoc />
protected override async Task OnInitializedAsync()
diff --git a/src/AliasVault.Client/Main/Models/CredentialEdit.cs b/src/AliasVault.Client/Main/Models/CredentialEdit.cs
index 50163c8dd..649dae4f3 100644
--- a/src/AliasVault.Client/Main/Models/CredentialEdit.cs
+++ b/src/AliasVault.Client/Main/Models/CredentialEdit.cs
@@ -27,19 +27,19 @@ public sealed class CredentialEdit
/// <summary>
/// Gets or sets notes field (free text input).
/// </summary>
- public string Notes { get; set; } = null!;
+ public string Notes { get; set; } = string.Empty;
/// <summary>
/// Gets or sets username field.
/// </summary>
- public string Username { get; set; } = null!;
+ public string Username { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the name of the service.
/// </summary>
[Required]
[Display(Name = "Service Name")]
- public string ServiceName { get; set; } = null!;
+ public string ServiceName { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the URL of the service.
@@ -49,7 +49,7 @@ public sealed class CredentialEdit
/// <summary>
/// Gets or sets the logo of the service.
/// </summary>
- public byte[]? ServiceLogo { get; set; } = null;
+ public byte[]? ServiceLogo { get; set; }
/// <summary>
/// Gets or sets the Alias Identity object.
@@ -60,7 +60,7 @@ public sealed class CredentialEdit
/// Gets or sets the Alias BirthDate.
/// </summary>
[StringDateFormat("yyyy-MM-dd")]
- public string AliasBirthDate { get; set; } = null!;
+ public string AliasBirthDate { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the Alias Password object.
diff --git a/src/Databases/AliasClientDb/AliasClientDbContext.cs b/src/Databases/AliasClientDb/AliasClientDbContext.cs
index 272af3d29..5e7a0137e 100644
--- a/src/Databases/AliasClientDb/AliasClientDbContext.cs
+++ b/src/Databases/AliasClientDb/AliasClientDbContext.cs
@@ -46,37 +46,37 @@ public class AliasClientDbContext : DbContext
/// <summary>
/// Gets or sets the Alias DbSet.
/// </summary>
- public DbSet<Alias> Aliases { get; set; } = null!;
+ public DbSet<Alias> Aliases { get; set; }
/// <summary>
/// Gets or sets the Attachment DbSet.
/// </summary>
- public DbSet<Attachment> Attachments { get; set; } = null!;
+ public DbSet<Attachment> Attachments { get; set; }
/// <summary>
/// Gets or sets the Credential DbSet.
/// </summary>
- public DbSet<Credential> Credentials { get; set; } = null!;
+ public DbSet<Credential> Credentials { get; set; }
/// <summary>
/// Gets or sets the Password DbSet.
/// </summary>
- public DbSet<Password> Passwords { get; set; } = null!;
+ public DbSet<Password> Passwords { get; set; }
/// <summary>
/// Gets or sets the Service DbSet.
/// </summary>
- public DbSet<Service> Services { get; set; } = null!;
+ public DbSet<Service> Services { get; set; }
/// <summary>
/// Gets or sets the EncryptionKey DbSet.
/// </summary>
- public DbSet<EncryptionKey> EncryptionKeys { get; set; } = null!;
+ public DbSet<EncryptionKey> EncryptionKeys { get; set; }
/// <summary>
/// Gets or sets the Settings DbSet.
/// </summary>
- public DbSet<Setting> Settings { get; set; } = null!;
+ public DbSet<Setting> Settings { get; set; }
/// <summary>
/// The OnModelCreating method.
diff --git a/src/Databases/AliasClientDb/Attachment.cs b/src/Databases/AliasClientDb/Attachment.cs
index 3e4d547dd..0e0e08ba2 100644
--- a/src/Databases/AliasClientDb/Attachment.cs
+++ b/src/Databases/AliasClientDb/Attachment.cs
@@ -26,7 +26,7 @@ public class Attachment : SyncableEntity
/// Gets or sets the filename value.
/// </summary>
[StringLength(255)]
- public string Filename { get; set; } = null!;
+ public string Filename { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the file blob.
diff --git a/src/Generators/AliasVault.Generators.Identity/Models/Identity.cs b/src/Generators/AliasVault.Generators.Identity/Models/Identity.cs
index 22cd6e4e1..a0614f575 100644
--- a/src/Generators/AliasVault.Generators.Identity/Models/Identity.cs
+++ b/src/Generators/AliasVault.Generators.Identity/Models/Identity.cs
@@ -12,11 +12,6 @@ namespace AliasVault.Generators.Identity.Models;
/// </summary>
public class Identity
{
- /// <summary>
- /// Gets or sets the id.
- /// </summary>
- public string Id { get; set; } = null!;
-
/// <summary>
/// Gets or sets the gender.
/// </summary>
@@ -25,17 +20,17 @@ public class Identity
/// <summary>
/// Gets or sets the first name.
/// </summary>
- public string FirstName { get; set; } = null!;
+ public string FirstName { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the last name.
/// </summary>
- public string LastName { get; set; } = null!;
+ public string LastName { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the nickname. This is also used as the username.
/// </summary>
- public string NickName { get; set; } = null!;
+ public string NickName { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the birth date.
@@ -45,5 +40,5 @@ public class Identity
/// <summary>
/// Gets or sets the email address prefix.
/// </summary>
- public string EmailPrefix { get; set; } = null!;
+ public string EmailPrefix { get; set; } = string.Empty;
}
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/EmailDecryptionTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/EmailDecryptionTests.cs
index ddfa98529..61f982c8b 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/EmailDecryptionTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/EmailDecryptionTests.cs
@@ -25,12 +25,12 @@ public class EmailDecryptionTests : ClientPlaywrightTest
/// <summary>
/// The test host instance.
/// </summary>
- private IHost _testHost = null!;
+ private IHost _testHost;
/// <summary>
/// The test host builder instance.
/// </summary>
- private TestHostBuilder _testHostBuilder = null!;
+ private TestHostBuilder _testHostBuilder;
/// <summary>
/// Setup logic for every test.