support for rewriting null conditional access expressions

This commit is contained in:
Koen Bekkenutte
2021-10-18 22:36:06 +08:00
parent 654dcba6ff
commit 86223a11c9
29 changed files with 682 additions and 11 deletions
@@ -0,0 +1,30 @@
namespace EntityFrameworkCore.Projectables
{
/// <summary>
/// Configures how null-conditional operators are handeled
/// </summary>
public enum NullConditionalRewriteSupport
{
/// <summary>
/// Don't rewrite null conditional operators (Default behavior).
/// Usage of null conditional operators is thereby not allowed
/// </summary>
None,
/// <summary>
/// Ignore null-conditional operators in the generated expression tree
/// </summary>
/// <remarks>
/// <c>(A?.B)</c> is rewritten as expression: <c>(A.B)</c>
/// </remarks>
Ignore,
/// <summary>
/// Translates null-conditional operators into explicit null checks
/// </summary>
/// <remarks>
/// <c>(A?.B)</c> is rewritten as expression: <c>(A != null ? A.B : null)</c>
/// </remarks>
Rewrite
}
}
@@ -9,5 +9,6 @@ namespace EntityFrameworkCore.Projectables
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
public sealed class ProjectableAttribute : Attribute
{
public NullConditionalRewriteSupport NullConditionalRewriteSupport { get; set; }
}
}