Skip to content

Commit

Permalink
Remove RequiresErrorContext from TexlFunction (#381)
Browse files Browse the repository at this point in the history
Also ignored some warnings for function definitions
  • Loading branch information
CarlosFigueiraMSFT authored May 9, 2022
1 parent 14d7c65 commit 4860013
Show file tree
Hide file tree
Showing 66 changed files with 216 additions and 199 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ internal abstract class TexlFunction : IFunction
// Return true if this function can return a type with ExpandInfo.
public virtual bool CanReturnExpandInfo => false;

// Return true if this function requires error context info.
public virtual bool RequiresErrorContext => false;

// Return true if this function requires binding context info.
public virtual bool RequiresBindingContext => false;

Expand Down
10 changes: 6 additions & 4 deletions src/libraries/Microsoft.PowerFx.Core/Texl/Builtins/Acos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
using Microsoft.PowerFx.Core.Localization;
using Microsoft.PowerFx.Core.Types;

#pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1649 // File name should match first type name

namespace Microsoft.PowerFx.Core.Texl.Builtins
{
// Acos(number:n)
// Equivalent Excel function: acos
internal sealed class AcosFunction : MathOneArgFunction
{
public override bool RequiresErrorContext => true;

public AcosFunction()
: base("Acos", TexlStrings.AboutAcos, FunctionCategories.MathAndStat)
{
Expand All @@ -22,11 +23,12 @@ public AcosFunction()
// Table overload that computes the arc cosine of each item in the input table.
internal sealed class AcosTableFunction : MathOneArgTableFunction
{
public override bool RequiresErrorContext => true;

public AcosTableFunction()
: base("Acos", TexlStrings.AboutAcosT, FunctionCategories.Table)
{
}
}
}

#pragma warning restore SA1402 // File may only contain a single type
#pragma warning restore SA1649 // File name should match first type name
10 changes: 6 additions & 4 deletions src/libraries/Microsoft.PowerFx.Core/Texl/Builtins/Acot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
using Microsoft.PowerFx.Core.Localization;
using Microsoft.PowerFx.Core.Types;

#pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1649 // File name should match first type name

namespace Microsoft.PowerFx.Core.Texl.Builtins
{
// Acot(number:n)
// Equivalent Excel function: Acot
internal sealed class AcotFunction : MathOneArgFunction
{
public override bool RequiresErrorContext => true;

public AcotFunction()
: base("Acot", TexlStrings.AboutAcot, FunctionCategories.MathAndStat)
{
Expand All @@ -22,11 +23,12 @@ public AcotFunction()
// Table overload that computes the arc cotangent of each item in the input table.
internal sealed class AcotTableFunction : MathOneArgTableFunction
{
public override bool RequiresErrorContext => true;

public AcotTableFunction()
: base("Acot", TexlStrings.AboutAcotT, FunctionCategories.Table)
{
}
}
}

#pragma warning restore SA1402 // File may only contain a single type
#pragma warning restore SA1649 // File name should match first type name
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
using Microsoft.PowerFx.Core.Utils;
using Microsoft.PowerFx.Syntax;

#pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1649 // File name should match first type name

namespace Microsoft.PowerFx.Core.Texl.Builtins
{
// AddColumns(source:*[...], name:s, valueFunc:func<_>, name:s, valueFunc:func<_>, ...)
Expand Down Expand Up @@ -182,3 +185,6 @@ public override bool AllowsRowScopedParamDelegationExempted(int index)
}
}
}

#pragma warning restore SA1402 // File may only contain a single type
#pragma warning restore SA1649 // File name should match first type name
8 changes: 6 additions & 2 deletions src/libraries/Microsoft.PowerFx.Core/Texl/Builtins/AsType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
using Microsoft.PowerFx.Core.Utils;
using Microsoft.PowerFx.Syntax;

#pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1649 // File name should match first type name

namespace Microsoft.PowerFx.Core.Texl.Builtins
{
// AsType(record:P, table:*[]): ![]
internal sealed class AsTypeFunction : BuiltinFunction
{
public const string AsTypeInvariantFunctionName = "AsType";

public override bool RequiresErrorContext => true;

public override bool IsAsync => true;

public override bool CanReturnExpandInfo => true;
Expand Down Expand Up @@ -104,3 +105,6 @@ protected override bool RequiresPagedDataForParamCore(TexlNode[] args, int param
}
}
}

#pragma warning restore SA1402 // File may only contain a single type
#pragma warning restore SA1649 // File name should match first type name
12 changes: 7 additions & 5 deletions src/libraries/Microsoft.PowerFx.Core/Texl/Builtins/Asin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
using Microsoft.PowerFx.Core.Localization;
using Microsoft.PowerFx.Core.Types;

#pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1649 // File name should match first type name

namespace Microsoft.PowerFx.Core.Texl.Builtins
{
// Asin(number:n)
// Equivalent Excel function: Asin
internal sealed class AsinFunction : MathOneArgFunction
{
public override bool RequiresErrorContext => true;

public AsinFunction()
: base("Asin", TexlStrings.AboutAsin, FunctionCategories.MathAndStat)
{
Expand All @@ -22,11 +23,12 @@ public AsinFunction()
// Table overload that computes the arc sine values of each item in the input table.
internal sealed class AsinTableFunction : MathOneArgTableFunction
{
public override bool RequiresErrorContext => true;

public AsinTableFunction()
: base("Asin", TexlStrings.AboutAsinT, FunctionCategories.Table)
{
}
}
}
}

#pragma warning restore SA1402 // File may only contain a single type
#pragma warning restore SA1649 // File name should match first type name
10 changes: 6 additions & 4 deletions src/libraries/Microsoft.PowerFx.Core/Texl/Builtins/Atan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
using Microsoft.PowerFx.Core.Localization;
using Microsoft.PowerFx.Core.Types;

#pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1649 // File name should match first type name

namespace Microsoft.PowerFx.Core.Texl.Builtins
{
// Atan(number:n)
// Equivalent Excel function: Atan
internal sealed class AtanFunction : MathOneArgFunction
{
public override bool RequiresErrorContext => true;

public AtanFunction()
: base("Atan", TexlStrings.AboutAtan, FunctionCategories.MathAndStat)
{
Expand All @@ -22,11 +23,12 @@ public AtanFunction()
// Table overload that computes the arc tangent of each item in the input table.
internal sealed class AtanTableFunction : MathOneArgTableFunction
{
public override bool RequiresErrorContext => true;

public AtanTableFunction()
: base("Atan", TexlStrings.AboutAtanT, FunctionCategories.Table)
{
}
}
}

#pragma warning restore SA1402 // File may only contain a single type
#pragma warning restore SA1649 // File name should match first type name
8 changes: 6 additions & 2 deletions src/libraries/Microsoft.PowerFx.Core/Texl/Builtins/Atan2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
using Microsoft.PowerFx.Core.Localization;
using Microsoft.PowerFx.Core.Types;

#pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1649 // File name should match first type name

namespace Microsoft.PowerFx.Core.Texl.Builtins
{
// Atan2(number:x, number:y)
Expand All @@ -14,8 +17,6 @@ internal sealed class Atan2Function : BuiltinFunction
{
public override bool IsSelfContained => true;

public override bool RequiresErrorContext => true;

public Atan2Function()
: base(
"Atan2",
Expand All @@ -38,3 +39,6 @@ public Atan2Function()
public override bool SupportsParamCoercion => true;
}
}

#pragma warning restore SA1402 // File may only contain a single type
#pragma warning restore SA1649 // File name should match first type name
10 changes: 6 additions & 4 deletions src/libraries/Microsoft.PowerFx.Core/Texl/Builtins/Average.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
using Microsoft.PowerFx.Core.Localization;
using Microsoft.PowerFx.Core.Types;

#pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1649 // File name should match first type name

namespace Microsoft.PowerFx.Core.Texl.Builtins
{
// Average(arg1:n, arg2:n, ..., argN:n)
// Corresponding Excel function: Average
internal sealed class AverageFunction : StatisticalFunction
{
public override bool RequiresErrorContext => true;

public AverageFunction()
: base("Average", TexlStrings.AboutAverage, FunctionCategories.MathAndStat)
{
Expand All @@ -23,8 +24,6 @@ public AverageFunction()
// Corresponding DAX function: Average
internal sealed class AverageTableFunction : StatisticalTableFunction
{
public override bool RequiresErrorContext => true;

public override DelegationCapability FunctionDelegationCapability => DelegationCapability.Average;

public AverageTableFunction()
Expand All @@ -33,3 +32,6 @@ public AverageTableFunction()
}
}
}

#pragma warning restore SA1402 // File may only contain a single type
#pragma warning restore SA1649 // File name should match first type name
6 changes: 6 additions & 0 deletions src/libraries/Microsoft.PowerFx.Core/Texl/Builtins/Blank.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
using Microsoft.PowerFx.Core.Localization;
using Microsoft.PowerFx.Core.Types;

#pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1649 // File name should match first type name

namespace Microsoft.PowerFx.Core.Texl.Builtins
{
// Blank()
Expand Down Expand Up @@ -33,3 +36,6 @@ public BlankFunction()
}
}
}

#pragma warning restore SA1402 // File may only contain a single type
#pragma warning restore SA1649 // File name should match first type name
10 changes: 6 additions & 4 deletions src/libraries/Microsoft.PowerFx.Core/Texl/Builtins/Boolean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
using Microsoft.PowerFx.Core.Localization;
using Microsoft.PowerFx.Core.Types;

#pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1649 // File name should match first type name

namespace Microsoft.PowerFx.Core.Texl.Builtins
{
// Boolean(arg:s)
Expand All @@ -14,8 +17,6 @@ internal sealed class BooleanFunction : BuiltinFunction
{
public const string BooleanInvariantFunctionName = "Boolean";

public override bool RequiresErrorContext => true;

public override bool IsSelfContained => true;

public override bool SupportsParamCoercion => false;
Expand All @@ -34,8 +35,6 @@ public BooleanFunction()
// Boolean(arg:O)
internal sealed class BooleanFunction_UO : BuiltinFunction
{
public override bool RequiresErrorContext => true;

public override bool IsSelfContained => true;

public override bool SupportsParamCoercion => false;
Expand All @@ -56,3 +55,6 @@ public override string GetUniqueTexlRuntimeName(bool isPrefetching = false)
}
}
}

#pragma warning restore SA1402 // File may only contain a single type
#pragma warning restore SA1649 // File name should match first type name
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
using Microsoft.PowerFx.Core.Types;
using Microsoft.PowerFx.Core.Utils;

#pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1649 // File name should match first type name

namespace Microsoft.PowerFx.Core.Texl.Builtins
{
internal abstract class CalendarFunction : BuiltinFunction
Expand Down Expand Up @@ -61,4 +64,7 @@ public WeekdaysShortFunction()
{
}
}
}
}

#pragma warning restore SA1402 // File may only contain a single type
#pragma warning restore SA1649 // File name should match first type name
10 changes: 6 additions & 4 deletions src/libraries/Microsoft.PowerFx.Core/Texl/Builtins/Char.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
using Microsoft.PowerFx.Core.Utils;
using Microsoft.PowerFx.Syntax;

#pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1649 // File name should match first type name

namespace Microsoft.PowerFx.Core.Texl.Builtins
{
// Char(arg:n) : s
// Corresponding Excel function: Char
internal sealed class CharFunction : BuiltinFunction
{
public override bool RequiresErrorContext => true;

public override bool IsSelfContained => true;

public override bool SupportsParamCoercion => true;
Expand All @@ -36,8 +37,6 @@ public CharFunction()
// Char(arg:*[n]) : *[s]
internal sealed class CharTFunction : BuiltinFunction
{
public override bool RequiresErrorContext => true;

public override bool IsSelfContained => true;

public override bool SupportsParamCoercion => true;
Expand Down Expand Up @@ -79,3 +78,6 @@ public override bool CheckInvocation(TexlBinding binding, TexlNode[] args, DType
}
}
}

#pragma warning restore SA1402 // File may only contain a single type
#pragma warning restore SA1649 // File name should match first type name
8 changes: 7 additions & 1 deletion src/libraries/Microsoft.PowerFx.Core/Texl/Builtins/Clock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
using Microsoft.PowerFx.Core.Types;
using Microsoft.PowerFx.Core.Utils;

#pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1649 // File name should match first type name

namespace Microsoft.PowerFx.Core.Texl.Builtins
{
internal class ClockFunction : BuiltinFunction
Expand Down Expand Up @@ -61,4 +64,7 @@ public IsClock24Function()
yield return new TexlStrings.StringGetter[] { };
}
}
}
}

#pragma warning restore SA1402 // File may only contain a single type
#pragma warning restore SA1649 // File name should match first type name
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
using Microsoft.PowerFx.Core.Utils;
using Microsoft.PowerFx.Syntax;

#pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1649 // File name should match first type name

namespace Microsoft.PowerFx.Core.Texl.Builtins
{
// Coalesce(expression:E)
Expand Down Expand Up @@ -121,3 +124,6 @@ public override bool CheckInvocation(TexlBinding binding, TexlNode[] args, DType
}
}
}

#pragma warning restore SA1402 // File may only contain a single type
#pragma warning restore SA1649 // File name should match first type name
Loading

0 comments on commit 4860013

Please sign in to comment.