Undo breaking change in Features (#2744)

Followup to #2740
This changes Features.PowerFxV1 from property to field - which is binary
breaking change.
Undo the break  - but still keep as singleton. 

Add test.
This commit is contained in:
Mike Stall 2024-11-16 11:30:13 -08:00 коммит произвёл GitHub
Родитель dba83cfd1a
Коммит 2912f0c8c7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 37 добавлений и 1 удалений

Просмотреть файл

@ -94,7 +94,12 @@ namespace Microsoft.PowerFx
internal static readonly Features None = new Features();
public static readonly Features PowerFxV1 = new Features
/// <summary>
/// The default V1 Power Fx feature set.
/// </summary>
public static Features PowerFxV1 => _powerFxV1;
private static readonly Features _powerFxV1 = new Features
{
TableSyntaxDoesntWrapRecords = true,
ConsistentOneColumnTableResult = true,

Просмотреть файл

@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
using Xunit;
namespace Microsoft.PowerFx.Tests
{
public class FeaturesTest
{
[Fact]
public void Singleton()
{
// Ensure that we have a singleton - this is for performance reasons.
Assert.True(object.ReferenceEquals(Features.PowerFxV1, Features.PowerFxV1));
// Equality checks
Assert.True(Features.PowerFxV1 == Features.PowerFxV1);
Assert.False(Features.PowerFxV1 != Features.PowerFxV1);
Assert.True(object.ReferenceEquals(Features.None, Features.None));
}
[Fact]
public void Flag()
{
// Ensure the V1 object is actually initialized.
var v1 = Features.PowerFxV1;
Assert.True(v1.SupportColumnNamesAsIdentifiers);
}
}
}