Skip to content

Commit 9b1d4c8

Browse files
committed
#191 - csharp-14 null prop assignment
1 parent ab11cb7 commit 9b1d4c8

File tree

5 files changed

+7
-21
lines changed

5 files changed

+7
-21
lines changed

src/Domain/HydraScript.Domain.BackEnd/AddressedInstructions.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ public void Replace(IExecutableInstruction old, IExecutableInstruction @new)
4343
private void AddWithAddress(IExecutableInstruction instruction, IAddress newAddress)
4444
{
4545
var last = _addresses.Last;
46-
if (last is not null)
47-
last.Value.Next = newAddress;
46+
last?.Value.Next = newAddress;
4847

4948
var newNode = _addresses.AddLast(newAddress);
5049

@@ -66,10 +65,7 @@ public void Remove(IExecutableInstruction instruction)
6665
var nodeToRemove = _addressToNode[address];
6766

6867
var prev = nodeToRemove.Previous;
69-
if (prev is not null)
70-
{
71-
prev.Value.Next = nodeToRemove.Next?.Value!;
72-
}
68+
prev?.Value.Next = nodeToRemove.Next?.Value!;
7369

7470
_addressToNode.Remove(address);
7571
_instructions.Remove(nodeToRemove);

src/Domain/HydraScript.Domain.FrontEnd/Parser/Impl/Ast/Nodes/Expressions/AssignmentExpression.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public AssignmentExpression(
3131
public override void InitScope(Scope? scope = null)
3232
{
3333
base.InitScope(scope);
34-
if (DestinationType is not null)
35-
DestinationType.Scope = Scope;
34+
DestinationType?.Scope = Scope;
3635
}
3736

3837
protected override string NodeRepresentation() => "=";

src/Domain/HydraScript.Domain.FrontEnd/Parser/Impl/Ast/Nodes/Expressions/MemberExpression.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ public MemberExpression(
2828
AccessExpression? tail) : this(identifierReference)
2929
{
3030
AccessChain = accessChain;
31-
if (AccessChain is not null)
32-
{
33-
AccessChain.Parent = this;
34-
}
31+
AccessChain?.Parent = this;
3532

3633
Tail = tail;
3734
}

src/Domain/HydraScript.Domain.FrontEnd/Parser/Impl/Ast/Nodes/Statements/IfStatement.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@ public IfStatement(Expression test, Statement then, Statement? @else = null)
1717
Then = then;
1818
Then.Parent = this;
1919

20-
if (@else is not null)
21-
{
22-
Else = @else;
23-
Else.Parent = this;
24-
}
20+
Else = @else;
21+
Else?.Parent = this;
2522

2623
Children = Else is not null ? [Test, Then, Else] : [Test, Then];
2724
}

src/Domain/HydraScript.Domain.FrontEnd/Parser/Impl/Ast/Nodes/Statements/ReturnStatement.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ public partial class ReturnStatement : Statement
1010
public ReturnStatement(Expression? expression = null)
1111
{
1212
Expression = expression;
13-
if (Expression is not null)
14-
{
15-
Expression.Parent = this;
16-
}
13+
Expression?.Parent = this;
1714

1815
Children = Expression is not null ? [Expression] : [];
1916
}

0 commit comments

Comments
 (0)