Skip to content

Commit

Permalink
Remove use of Lazy in favour of null-coalescing assignment
Browse files Browse the repository at this point in the history
Co-authored-by: Greg Dennis <[email protected]>
  • Loading branch information
laurynasr and gregsdennis authored Jul 8, 2024
1 parent 054273f commit 0740fcf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Graeae.Models/SchemaDraft4/Draft4Support.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public static class Draft4Support
/// This property is initialized by the <see cref="Enable"/> method and
/// will be null if accessed before that method is called.
/// </remarks>
public static JsonSchema Draft4MetaSchema => _draft4MetaSchema.Value;
private static readonly Lazy<JsonSchema> _draft4MetaSchema = new Lazy<JsonSchema>(InitializeDraft4Schema);
private static readonly JsonSchema _draft4MetaSchema; // move this to the top of the class

Check warning on line 35 in Graeae.Models/SchemaDraft4/Draft4Support.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field '_draft4MetaSchema' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 35 in Graeae.Models/SchemaDraft4/Draft4Support.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field '_draft4MetaSchema' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
public static JsonSchema Draft4MetaSchema => _draft4MetaSchema ??= InitializeDraf4MetaSchema();

Check failure on line 36 in Graeae.Models/SchemaDraft4/Draft4Support.cs

View workflow job for this annotation

GitHub Actions / build

A static readonly field cannot be assigned to (except in a static constructor or a variable initializer)

Check failure on line 36 in Graeae.Models/SchemaDraft4/Draft4Support.cs

View workflow job for this annotation

GitHub Actions / build

The name 'InitializeDraf4MetaSchema' does not exist in the current context

Check failure on line 36 in Graeae.Models/SchemaDraft4/Draft4Support.cs

View workflow job for this annotation

GitHub Actions / build

A static readonly field cannot be assigned to (except in a static constructor or a variable initializer)

Check failure on line 36 in Graeae.Models/SchemaDraft4/Draft4Support.cs

View workflow job for this annotation

GitHub Actions / build

The name 'InitializeDraf4MetaSchema' does not exist in the current context

Check failure on line 36 in Graeae.Models/SchemaDraft4/Draft4Support.cs

View workflow job for this annotation

GitHub Actions / build

A static readonly field cannot be assigned to (except in a static constructor or a variable initializer)

Check failure on line 36 in Graeae.Models/SchemaDraft4/Draft4Support.cs

View workflow job for this annotation

GitHub Actions / build

The name 'InitializeDraf4MetaSchema' does not exist in the current context

Check failure on line 36 in Graeae.Models/SchemaDraft4/Draft4Support.cs

View workflow job for this annotation

GitHub Actions / build

A static readonly field cannot be assigned to (except in a static constructor or a variable initializer)

Check failure on line 36 in Graeae.Models/SchemaDraft4/Draft4Support.cs

View workflow job for this annotation

GitHub Actions / build

The name 'InitializeDraf4MetaSchema' does not exist in the current context

private static JsonSchema InitializeDraft4Schema()
{
Expand Down

0 comments on commit 0740fcf

Please sign in to comment.