Skip to content

Commit 6de8ade

Browse files
committed
Resharper: use field keyword
1 parent 72c62dd commit 6de8ade

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

test/JsonApiDotNetCoreTests/IntegrationTests/EagerLoading/Building.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ namespace JsonApiDotNetCoreTests.IntegrationTests.EagerLoading;
99
[Resource(ControllerNamespace = "JsonApiDotNetCoreTests.IntegrationTests.EagerLoading")]
1010
public sealed class Building : Identifiable<int>
1111
{
12-
private string? _tempPrimaryDoorColor;
13-
1412
[Attr]
1513
public string Number { get; set; } = null!;
1614

@@ -24,7 +22,7 @@ public string PrimaryDoorColor
2422
{
2523
get
2624
{
27-
if (_tempPrimaryDoorColor == null && PrimaryDoor == null)
25+
if (field == null && PrimaryDoor == null)
2826
{
2927
// The ASP.NET model validator reads the value of this required property, to ensure it is not null.
3028
// When creating a resource, BuildingDefinition ensures a value is assigned. But when updating a resource
@@ -33,15 +31,15 @@ public string PrimaryDoorColor
3331
return null!;
3432
}
3533

36-
return _tempPrimaryDoorColor ?? PrimaryDoor!.Color;
34+
return field ?? PrimaryDoor!.Color;
3735
}
3836
set
3937
{
4038
if (PrimaryDoor == null)
4139
{
4240
// A request body is being deserialized. At this time, related entities have not been loaded yet.
4341
// We cache the assigned value in a private field, so it can be used later.
44-
_tempPrimaryDoorColor = value;
42+
field = value;
4543
}
4644
else
4745
{

test/OpenApiNSwagClientTests/ChangeTracking/SerializerChangeTrackingTests.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -802,13 +802,11 @@ public async Task Can_track_multiple_times_in_same_request_document()
802802
[UsedImplicitly(ImplicitUseTargetFlags.Members)]
803803
private sealed class ComplexType : NotifyPropertySet
804804
{
805-
private DateTime? _nullableDateTime;
806-
807805
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore)]
808806
public DateTime? NullableDateTime
809807
{
810-
get => _nullableDateTime;
811-
set => SetProperty(ref _nullableDateTime, value);
808+
get;
809+
set => SetProperty(ref field, value);
812810
}
813811

814812
public NestedType? NestedType { get; set; }
@@ -817,21 +815,18 @@ public DateTime? NullableDateTime
817815
[UsedImplicitly(ImplicitUseTargetFlags.Members)]
818816
private sealed class NestedType : NotifyPropertySet
819817
{
820-
private int? _nullableInt;
821-
private string? _nullableString;
822-
823818
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore)]
824819
public int? NullableInt
825820
{
826-
get => _nullableInt;
827-
set => SetProperty(ref _nullableInt, value);
821+
get;
822+
set => SetProperty(ref field, value);
828823
}
829824

830825
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore)]
831826
public string? NullableString
832827
{
833-
get => _nullableString;
834-
set => SetProperty(ref _nullableString, value);
828+
get;
829+
set => SetProperty(ref field, value);
835830
}
836831
}
837832

0 commit comments

Comments
 (0)