Skip to content

Commit 75a15bf

Browse files
committed
Deprecate IFunction.Expression
1 parent 9c0c516 commit 75a15bf

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

src/Acornima.Extras/AstToJsonConverter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,9 @@ private IFunction VisitFunction(IFunction node)
578578
Member("params", node.Params);
579579
Member("body", node.Body);
580580
Member("generator", node.Generator);
581+
#pragma warning disable CS0618 // Type or member is obsolete
581582
Member("expression", node.Expression);
583+
#pragma warning restore CS0618 // Type or member is obsolete
582584
Member("async", node.Async);
583585
}
584586

src/Acornima/Ast/ArrowFunctionExpression.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Runtime.CompilerServices;
23

34
namespace Acornima.Ast;
@@ -16,7 +17,9 @@ public ArrowFunctionExpression(
1617
{
1718
_params = parameters;
1819
Body = body;
20+
#pragma warning disable CS0618 // Type or member is obsolete
1921
Expression = expression;
22+
#pragma warning restore CS0618 // Type or member is obsolete
2023
Async = async;
2124
}
2225

@@ -30,11 +33,14 @@ public ArrowFunctionExpression(
3033
/// </remarks>
3134
public StatementOrExpression Body { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; }
3235
bool IFunction.Generator => false;
36+
[Obsolete("This property is deprecated in the ESTree specification and therefore will be removed from the public API in a future major version.")]
3337
public bool Expression { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; }
3438
public bool Async { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; }
3539

3640
private ArrowFunctionExpression Rewrite(in NodeList<Node> @params, StatementOrExpression body)
3741
{
42+
#pragma warning disable CS0618 // Type or member is obsolete
3843
return new ArrowFunctionExpression(@params, body, Expression, Async);
44+
#pragma warning restore CS0618 // Type or member is obsolete
3945
}
4046
}

src/Acornima/Ast/IFunction.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System;
2+
13
namespace Acornima.Ast;
24

35
/// <summary>
@@ -8,6 +10,7 @@ public interface IFunction : INode
810
Identifier? Id { get; }
911
ref readonly NodeList<Node> Params { get; }
1012
StatementOrExpression Body { get; }
13+
[Obsolete("This property is deprecated in the ESTree specification and therefore will be removed from the public API in a future major version.")]
1114
bool Expression { get; }
1215
bool Generator { get; }
1316
bool Async { get; }

test/Acornima.Tests/AstRewriterTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,9 @@ private T ForceNewObjectByControlType<T>(T node, Func<T, T> createNew)
340340
protected internal override object? VisitArrowFunctionExpression(ArrowFunctionExpression arrowFunctionExpression)
341341
{
342342
return ForceNewObjectByControlType((ArrowFunctionExpression)base.VisitArrowFunctionExpression(arrowFunctionExpression)!,
343+
#pragma warning disable CS0618 // Type or member is obsolete
343344
node => new ArrowFunctionExpression(node.Params, node.Body, node.Expression, node.Async));
345+
#pragma warning restore CS0618 // Type or member is obsolete
344346
}
345347

346348
protected internal override object? VisitUnaryExpression(UnaryExpression unaryExpression)

0 commit comments

Comments
 (0)