diff --git a/src/libraries/Microsoft.PowerFx.Core/Public/Values/CompileTimeTypeWrapperRecordValue.cs b/src/libraries/Microsoft.PowerFx.Core/Public/Values/CompileTimeTypeWrapperRecordValue.cs index 6092c6ff4..4460a152f 100644 --- a/src/libraries/Microsoft.PowerFx.Core/Public/Values/CompileTimeTypeWrapperRecordValue.cs +++ b/src/libraries/Microsoft.PowerFx.Core/Public/Values/CompileTimeTypeWrapperRecordValue.cs @@ -43,11 +43,11 @@ namespace Microsoft.PowerFx.Types protected override bool TryGetField(FormulaType fieldType, string fieldName, out FormulaValue result) { - if (Type.TryGetFieldType(fieldName, out var compileTimeType)) + if (Type.TryGetFieldType(fieldName, out var logical, out var compileTimeType)) { // Only return field which were specified via the expectedType (IE RecordType), // because inner record value may have more fields than the expected type. - if (compileTimeType == fieldType && _fields.TryGetValue(fieldName, out result)) + if (compileTimeType == fieldType && _fields.TryGetValue(logical, out result)) { return true; } diff --git a/src/libraries/Microsoft.PowerFx.Interpreter/Environment/PowerFxConfigExtensions.cs b/src/libraries/Microsoft.PowerFx.Interpreter/Environment/PowerFxConfigExtensions.cs index ebdaa102c..69db48a8a 100644 --- a/src/libraries/Microsoft.PowerFx.Interpreter/Environment/PowerFxConfigExtensions.cs +++ b/src/libraries/Microsoft.PowerFx.Interpreter/Environment/PowerFxConfigExtensions.cs @@ -7,6 +7,7 @@ using Microsoft.PowerFx.Core.Functions; using Microsoft.PowerFx.Core.Texl.Builtins; using Microsoft.PowerFx.Functions; using Microsoft.PowerFx.Interpreter; +using Microsoft.PowerFx.Types; namespace Microsoft.PowerFx { @@ -22,6 +23,12 @@ namespace Microsoft.PowerFx symbolTable.AddFunction(function.GetTexlFunction()); } + public static void AddEnvironmentVariables(this SymbolValues symbolValues, RecordValue recordValue) + { + var variablesRecordValue = FormulaValue.NewRecordFromFields(new NamedValue("Variables", recordValue)); + symbolValues.Add("Environment", variablesRecordValue); + } + /// /// Enable a Set() function which allows scripts to do . /// diff --git a/src/tests/Microsoft.PowerFx.Core.Tests.Shared/Helpers/TestTabularDataSource.cs b/src/tests/Microsoft.PowerFx.Core.Tests.Shared/Helpers/TestTabularDataSource.cs index cfc294576..3baccab4f 100644 --- a/src/tests/Microsoft.PowerFx.Core.Tests.Shared/Helpers/TestTabularDataSource.cs +++ b/src/tests/Microsoft.PowerFx.Core.Tests.Shared/Helpers/TestTabularDataSource.cs @@ -124,7 +124,7 @@ namespace Microsoft.PowerFx.Core.Tests.Helpers public DType Schema => throw new NotImplementedException(); - public BidirectionalDictionary DisplayNameMapping => throw new NotImplementedException(); + public BidirectionalDictionary DisplayNameMapping => new BidirectionalDictionary(); public BidirectionalDictionary PreviousDisplayNameMapping => throw new NotImplementedException();