-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed reason reported for startsWith #1818
- Loading branch information
1 parent
6354e3b
commit b45440b
Showing
20 changed files
with
646 additions
and
534 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
namespace PSRule.Definitions.Expressions; | ||
|
||
internal sealed class ExpressionInfo | ||
{ | ||
private readonly string _Path; | ||
|
||
public ExpressionInfo(string path) | ||
{ | ||
_Path = path; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Diagnostics; | ||
|
||
namespace PSRule.Definitions.Expressions; | ||
|
||
/// <summary> | ||
/// A structure describing a specific function. | ||
/// </summary> | ||
[DebuggerDisplay("Function: {Name}")] | ||
internal sealed class FunctionDescriptor : IFunctionDescriptor | ||
{ | ||
public FunctionDescriptor(string name, ExpressionBuilderFn fn) | ||
{ | ||
Name = name; | ||
Fn = fn; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public string Name { get; } | ||
|
||
/// <inheritdoc/> | ||
public ExpressionBuilderFn Fn { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
namespace PSRule.Definitions.Expressions; | ||
|
||
internal sealed class FunctionFactory | ||
{ | ||
private readonly Dictionary<string, IFunctionDescriptor> _Descriptors; | ||
|
||
public FunctionFactory() | ||
{ | ||
_Descriptors = new Dictionary<string, IFunctionDescriptor>(StringComparer.OrdinalIgnoreCase); | ||
foreach (var d in Functions.Builtin) | ||
With(d); | ||
} | ||
|
||
public bool TryDescriptor(string name, out IFunctionDescriptor descriptor) | ||
{ | ||
return _Descriptors.TryGetValue(name, out descriptor); | ||
} | ||
|
||
public void With(IFunctionDescriptor descriptor) | ||
{ | ||
_Descriptors.Add(descriptor.Name, descriptor); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
namespace PSRule.Definitions.Expressions; | ||
|
||
internal abstract class FunctionReader | ||
{ | ||
public abstract bool TryProperty(out string propertyName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using PSRule.Pipeline; | ||
using PSRule.Runtime; | ||
|
||
namespace PSRule.Definitions.Expressions; | ||
|
||
internal interface IExpressionContext : IBindingContext | ||
{ | ||
ResourceKind Kind { get; } | ||
|
||
SourceFile Source { get; } | ||
|
||
string LanguageScope { get; } | ||
|
||
void Reason(IOperand operand, string text, params object[] args); | ||
|
||
void Debug(string message, params object[] args); | ||
|
||
object Current { get; } | ||
|
||
RunspaceContext Context { get; } | ||
|
||
void PushScope(RunspaceScope scope); | ||
|
||
void PopScope(RunspaceScope scope); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
namespace PSRule.Definitions.Expressions; | ||
|
||
/// <summary> | ||
/// A structure describing a specific function. | ||
/// </summary> | ||
internal interface IFunctionDescriptor | ||
{ | ||
/// <summary> | ||
/// The name of the function. | ||
/// </summary> | ||
string Name { get; } | ||
|
||
/// <summary> | ||
/// The function delegate. | ||
/// </summary> | ||
ExpressionBuilderFn Fn { get; } | ||
} |
Oops, something went wrong.