You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "gurustron (via GitHub)" <gi...@apache.org> on 2026/04/04 13:36:49 UTC

[PR] IGNITE-27068 .NET: Thin 3.0: Support in LINQ C# 14 span methods [ignite-3]

gurustron opened a new pull request, #7933:
URL: https://github.com/apache/ignite-3/pull/7933

   Thank you for submitting the pull request.
   
   To streamline the review process of the patch and ensure better code quality
   we ask both an author and a reviewer to verify the following:
   
   ### The Review Checklist
   - [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:  
   \- There is a single JIRA ticket related to the pull request.  
   \- The web-link to the pull request is attached to the JIRA ticket.  
   \- The JIRA ticket has the Patch Available state.  
   \- The description of the JIRA ticket explains WHAT was made, WHY and HOW.  
   \- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
   - [ ] **Design:** new code conforms with the design principles of the components it is added to.
   - [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
   - [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
   - [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
   
   ### Notes
   - [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27068 .NET: LINQ: Support C# 14 span methods [ignite-3]

Posted by "ptupitsyn (via GitHub)" <gi...@apache.org>.
ptupitsyn commented on code in PR #7933:
URL: https://github.com/apache/ignite-3/pull/7933#discussion_r3038401368


##########
modules/platforms/dotnet/Apache.Ignite/Internal/Linq/IgniteQueryParser.cs:
##########
@@ -78,16 +85,77 @@ private static CompoundExpressionTreeProcessor CreateCompoundProcessor(
         return new CompoundExpressionTreeProcessor(
             new IExpressionTreeProcessor[]
             {
-                new PartialEvaluatingExpressionTreeProcessor(new NullEvaluatableExpressionFilter()),
+                new PartialEvaluatingExpressionTreeProcessor(new IgniteEvaluatableExpressionFilter()),
                 new TransformingExpressionTreeProcessor(transformationProvider)
             });
     }
 
     /// <summary>
-    /// Empty implementation of IEvaluatableExpressionFilter.
+    /// Implementation of IEvaluatableExpressionFilter.
     /// </summary>
-    private sealed class NullEvaluatableExpressionFilter : EvaluatableExpressionFilterBase
+    private sealed class IgniteEvaluatableExpressionFilter : EvaluatableExpressionFilterBase
     {
-        // No-op.
+        // Ignores implicit ReadOnlySpan conversion to support C# 14 first class span Contains.
+        public override bool IsEvaluatableMethodCall(MethodCallExpression node)
+        {
+            ArgumentNullException.ThrowIfNull(node);
+            if (MemoryExtensionsContainsExpressionTransformer.IsSpanImplicitConversion(node))
+            {
+                return false;
+            }
+
+            return base.IsEvaluatableMethodCall(node);
+        }
+    }
+
+    /// <summary>
+    /// Implementation of IExpressionTransformer handling C# 14 first class span Contains.
+    /// </summary>
+    private sealed class MemoryExtensionsContainsExpressionTransformer : IExpressionTransformer<MethodCallExpression>
+    {
+        private static readonly MethodInfo SourceMethodInfo = typeof(MemoryExtensions)
+            .GetMethod(nameof(MemoryExtensions.Contains), [
+                typeof(ReadOnlySpan<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
+                Type.MakeGenericMethodParameter(0)
+            ])!;
+
+        private static readonly MethodInfo TargetMethodInfo = typeof(Enumerable)
+            .GetMethod(nameof(Enumerable.Contains), [
+                typeof(IEnumerable<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
+                Type.MakeGenericMethodParameter(0)
+            ])!;
+
+#pragma warning disable CA1819
+        public ExpressionType[] SupportedExpressionTypes => [ExpressionType.Call];
+#pragma warning restore CA1819
+
+        public static bool IsSpanImplicitConversion([NotNullWhen(true)]MethodCallExpression? node) =>
+            node?.Method is { IsSpecialName: true, Name: "op_Implicit" }
+            && node.Method.DeclaringType is { IsGenericType: true }
+            && node.Method.DeclaringType.GetGenericTypeDefinition() == typeof(ReadOnlySpan<>);
+
+        public Expression Transform(MethodCallExpression expression)
+        {
+            if (expression.Method.IsConstructedGenericMethod && expression.Method.GetGenericMethodDefinition() == SourceMethodInfo)

Review Comment:
   Fair enough :+1: 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27068 .NET: LINQ: Support C# 14 span methods [ignite-3]

Posted by "ptupitsyn (via GitHub)" <gi...@apache.org>.
ptupitsyn commented on code in PR #7933:
URL: https://github.com/apache/ignite-3/pull/7933#discussion_r3038363207


##########
modules/platforms/dotnet/Apache.Ignite/Internal/Linq/IgniteQueryParser.cs:
##########
@@ -78,16 +85,77 @@ private static CompoundExpressionTreeProcessor CreateCompoundProcessor(
         return new CompoundExpressionTreeProcessor(
             new IExpressionTreeProcessor[]
             {
-                new PartialEvaluatingExpressionTreeProcessor(new NullEvaluatableExpressionFilter()),
+                new PartialEvaluatingExpressionTreeProcessor(new IgniteEvaluatableExpressionFilter()),
                 new TransformingExpressionTreeProcessor(transformationProvider)
             });
     }
 
     /// <summary>
-    /// Empty implementation of IEvaluatableExpressionFilter.
+    /// Implementation of IEvaluatableExpressionFilter.
     /// </summary>
-    private sealed class NullEvaluatableExpressionFilter : EvaluatableExpressionFilterBase
+    private sealed class IgniteEvaluatableExpressionFilter : EvaluatableExpressionFilterBase
     {
-        // No-op.
+        // Ignores implicit ReadOnlySpan conversion to support C# 14 first class span Contains.
+        public override bool IsEvaluatableMethodCall(MethodCallExpression node)
+        {
+            ArgumentNullException.ThrowIfNull(node);
+            if (MemoryExtensionsContainsExpressionTransformer.IsSpanImplicitConversion(node))
+            {
+                return false;
+            }
+
+            return base.IsEvaluatableMethodCall(node);
+        }
+    }
+
+    /// <summary>
+    /// Implementation of IExpressionTransformer handling C# 14 first class span Contains.
+    /// </summary>
+    private sealed class MemoryExtensionsContainsExpressionTransformer : IExpressionTransformer<MethodCallExpression>
+    {
+        private static readonly MethodInfo SourceMethodInfo = typeof(MemoryExtensions)
+            .GetMethod(nameof(MemoryExtensions.Contains), [
+                typeof(ReadOnlySpan<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
+                Type.MakeGenericMethodParameter(0)
+            ])!;
+
+        private static readonly MethodInfo TargetMethodInfo = typeof(Enumerable)
+            .GetMethod(nameof(Enumerable.Contains), [
+                typeof(IEnumerable<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
+                Type.MakeGenericMethodParameter(0)
+            ])!;
+
+#pragma warning disable CA1819
+        public ExpressionType[] SupportedExpressionTypes => [ExpressionType.Call];
+#pragma warning restore CA1819
+
+        public static bool IsSpanImplicitConversion([NotNullWhen(true)]MethodCallExpression? node) =>
+            node?.Method is { IsSpecialName: true, Name: "op_Implicit" }
+            && node.Method.DeclaringType is { IsGenericType: true }
+            && node.Method.DeclaringType.GetGenericTypeDefinition() == typeof(ReadOnlySpan<>);
+
+        public Expression Transform(MethodCallExpression expression)
+        {
+            if (expression.Method.IsConstructedGenericMethod && expression.Method.GetGenericMethodDefinition() == SourceMethodInfo)

Review Comment:
   Invert if to reduce nesting?



##########
modules/platforms/dotnet/Apache.Ignite/Internal/Linq/IgniteQueryParser.cs:
##########
@@ -78,16 +85,77 @@ private static CompoundExpressionTreeProcessor CreateCompoundProcessor(
         return new CompoundExpressionTreeProcessor(
             new IExpressionTreeProcessor[]
             {
-                new PartialEvaluatingExpressionTreeProcessor(new NullEvaluatableExpressionFilter()),
+                new PartialEvaluatingExpressionTreeProcessor(new IgniteEvaluatableExpressionFilter()),
                 new TransformingExpressionTreeProcessor(transformationProvider)
             });
     }
 
     /// <summary>
-    /// Empty implementation of IEvaluatableExpressionFilter.
+    /// Implementation of IEvaluatableExpressionFilter.
     /// </summary>
-    private sealed class NullEvaluatableExpressionFilter : EvaluatableExpressionFilterBase
+    private sealed class IgniteEvaluatableExpressionFilter : EvaluatableExpressionFilterBase
     {
-        // No-op.
+        // Ignores implicit ReadOnlySpan conversion to support C# 14 first class span Contains.
+        public override bool IsEvaluatableMethodCall(MethodCallExpression node)
+        {
+            ArgumentNullException.ThrowIfNull(node);
+            if (MemoryExtensionsContainsExpressionTransformer.IsSpanImplicitConversion(node))
+            {
+                return false;
+            }
+
+            return base.IsEvaluatableMethodCall(node);
+        }
+    }
+
+    /// <summary>
+    /// Implementation of IExpressionTransformer handling C# 14 first class span Contains.
+    /// </summary>
+    private sealed class MemoryExtensionsContainsExpressionTransformer : IExpressionTransformer<MethodCallExpression>
+    {
+        private static readonly MethodInfo SourceMethodInfo = typeof(MemoryExtensions)
+            .GetMethod(nameof(MemoryExtensions.Contains), [
+                typeof(ReadOnlySpan<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
+                Type.MakeGenericMethodParameter(0)
+            ])!;
+
+        private static readonly MethodInfo TargetMethodInfo = typeof(Enumerable)
+            .GetMethod(nameof(Enumerable.Contains), [
+                typeof(IEnumerable<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
+                Type.MakeGenericMethodParameter(0)
+            ])!;
+
+#pragma warning disable CA1819
+        public ExpressionType[] SupportedExpressionTypes => [ExpressionType.Call];
+#pragma warning restore CA1819

Review Comment:
   ```suggestion
           [SuppressMessage("Performance", "CA1819:Properties should not return arrays", Justification = "Interface impl")]
           public ExpressionType[] SupportedExpressionTypes => [ExpressionType.Call];
   ```



##########
modules/platforms/dotnet/Apache.Ignite/Internal/Linq/IgniteQueryParser.cs:
##########
@@ -78,16 +85,77 @@ private static CompoundExpressionTreeProcessor CreateCompoundProcessor(
         return new CompoundExpressionTreeProcessor(
             new IExpressionTreeProcessor[]
             {
-                new PartialEvaluatingExpressionTreeProcessor(new NullEvaluatableExpressionFilter()),
+                new PartialEvaluatingExpressionTreeProcessor(new IgniteEvaluatableExpressionFilter()),
                 new TransformingExpressionTreeProcessor(transformationProvider)
             });
     }
 
     /// <summary>
-    /// Empty implementation of IEvaluatableExpressionFilter.
+    /// Implementation of IEvaluatableExpressionFilter.
     /// </summary>
-    private sealed class NullEvaluatableExpressionFilter : EvaluatableExpressionFilterBase
+    private sealed class IgniteEvaluatableExpressionFilter : EvaluatableExpressionFilterBase
     {
-        // No-op.
+        // Ignores implicit ReadOnlySpan conversion to support C# 14 first class span Contains.
+        public override bool IsEvaluatableMethodCall(MethodCallExpression node)
+        {
+            ArgumentNullException.ThrowIfNull(node);
+            if (MemoryExtensionsContainsExpressionTransformer.IsSpanImplicitConversion(node))
+            {
+                return false;
+            }
+
+            return base.IsEvaluatableMethodCall(node);
+        }
+    }
+
+    /// <summary>
+    /// Implementation of IExpressionTransformer handling C# 14 first class span Contains.
+    /// </summary>
+    private sealed class MemoryExtensionsContainsExpressionTransformer : IExpressionTransformer<MethodCallExpression>
+    {
+        private static readonly MethodInfo SourceMethodInfo = typeof(MemoryExtensions)
+            .GetMethod(nameof(MemoryExtensions.Contains), [
+                typeof(ReadOnlySpan<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
+                Type.MakeGenericMethodParameter(0)
+            ])!;
+
+        private static readonly MethodInfo TargetMethodInfo = typeof(Enumerable)
+            .GetMethod(nameof(Enumerable.Contains), [
+                typeof(IEnumerable<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
+                Type.MakeGenericMethodParameter(0)
+            ])!;
+
+#pragma warning disable CA1819
+        public ExpressionType[] SupportedExpressionTypes => [ExpressionType.Call];
+#pragma warning restore CA1819
+
+        public static bool IsSpanImplicitConversion([NotNullWhen(true)]MethodCallExpression? node) =>
+            node?.Method is { IsSpecialName: true, Name: "op_Implicit" }
+            && node.Method.DeclaringType is { IsGenericType: true }
+            && node.Method.DeclaringType.GetGenericTypeDefinition() == typeof(ReadOnlySpan<>);

Review Comment:
   ```suggestion
           public static bool IsSpanImplicitConversion([NotNullWhen(true)] MethodCallExpression? node) =>
               node?.Method is { IsSpecialName: true, Name: "op_Implicit", DeclaringType.IsGenericType: true }
               && node.Method.DeclaringType.GetGenericTypeDefinition() == typeof(ReadOnlySpan<>);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27068 .NET: Thin 3.0: Support in LINQ C# 14 span methods [ignite-3]

Posted by "gurustron (via GitHub)" <gi...@apache.org>.
gurustron commented on code in PR #7933:
URL: https://github.com/apache/ignite-3/pull/7933#discussion_r3035605197


##########
modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.cs:
##########
@@ -158,6 +158,14 @@ public void TestSelectOrderByOffsetLimit() =>
                 .Take(3)
                 .ToList());
 
+    [Test]
+    public void TestContains() =>
+        AssertSql("select (_T0.KEY IN (?, ?)) from PUBLIC.TBL1 as _T0", q =>
+        {
+            var keys = new long[] { 4, 2 };
+            return q.Select(x => keys.Contains(x.Key)).ToList();
+        });

Review Comment:
   Yes, I know, nothing can be done here since it will require casting to span in an expression tree which is not possible 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27068 .NET: Thin 3.0: Support in LINQ C# 14 span methods [ignite-3]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #7933:
URL: https://github.com/apache/ignite-3/pull/7933#discussion_r3035599059


##########
modules/platforms/dotnet/Apache.Ignite/Internal/Linq/IgniteQueryParser.cs:
##########
@@ -78,16 +86,79 @@ private static CompoundExpressionTreeProcessor CreateCompoundProcessor(
         return new CompoundExpressionTreeProcessor(
             new IExpressionTreeProcessor[]
             {
-                new PartialEvaluatingExpressionTreeProcessor(new NullEvaluatableExpressionFilter()),
+                new PartialEvaluatingExpressionTreeProcessor(new IgniteEvaluatableExpressionFilter()),
                 new TransformingExpressionTreeProcessor(transformationProvider)
             });
     }
 
     /// <summary>
-    /// Empty implementation of IEvaluatableExpressionFilter.
+    /// Implementation of IEvaluatableExpressionFilter.
     /// </summary>
-    private sealed class NullEvaluatableExpressionFilter : EvaluatableExpressionFilterBase
+    private sealed class IgniteEvaluatableExpressionFilter : EvaluatableExpressionFilterBase
     {
-        // No-op.
+        // Ignores implicit ReadOnlySpan conversion to support C# 14 first class span Contains.
+        public override bool IsEvaluatableMethodCall(MethodCallExpression node)
+        {
+            ArgumentNullException.ThrowIfNull(node);
+            if (MemoryExtensionsContainsExpressionTransformer.IsSpanImplicitConversion(node))
+            {
+                return false;
+            }
+
+            return base.IsEvaluatableMethodCall(node);
+        }
+    }
+
+    /// <summary>
+    /// Implementation of IExpressionTransformer handling C# 14 first class span Contains.
+    /// </summary>
+    private sealed class MemoryExtensionsContainsExpressionTransformer : IExpressionTransformer<MethodCallExpression>
+    {
+        private static readonly MethodInfo SourceMethodInfo = typeof(MemoryExtensions)
+            .GetMethod(nameof(MemoryExtensions.Contains), [
+                typeof(ReadOnlySpan<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
+                Type.MakeGenericMethodParameter(0)
+            ])!;
+
+        private static readonly MethodInfo TargetMethodInfo = typeof(Enumerable)
+            .GetMethod(nameof(Enumerable.Contains), [
+                typeof(IEnumerable<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
+                Type.MakeGenericMethodParameter(0)
+            ])!;

Review Comment:
   `TargetMethodInfo` is obtained via reflection (`typeof(Enumerable).GetMethod(...)`) and then invoked via `MakeGenericMethod`. Since `Apache.Ignite` is marked trimmable, this kind of reflection can break in trimmed apps if the linker removes the `Enumerable.Contains` overload. Prefer a direct method reference (e.g., obtain `MethodInfo` from a closed generic delegate and call `GetGenericMethodDefinition()`), or add the necessary trimming annotations/dependencies to ensure the method is preserved.
   ```suggestion
           private static readonly MethodInfo TargetMethodInfo =
               ((Func<IEnumerable<int>, int, bool>)Enumerable.Contains).Method.GetGenericMethodDefinition();
   ```



##########
modules/platforms/dotnet/Apache.Ignite/Internal/Linq/IgniteQueryParser.cs:
##########
@@ -78,16 +86,79 @@ private static CompoundExpressionTreeProcessor CreateCompoundProcessor(
         return new CompoundExpressionTreeProcessor(
             new IExpressionTreeProcessor[]
             {
-                new PartialEvaluatingExpressionTreeProcessor(new NullEvaluatableExpressionFilter()),
+                new PartialEvaluatingExpressionTreeProcessor(new IgniteEvaluatableExpressionFilter()),
                 new TransformingExpressionTreeProcessor(transformationProvider)
             });
     }
 
     /// <summary>
-    /// Empty implementation of IEvaluatableExpressionFilter.
+    /// Implementation of IEvaluatableExpressionFilter.
     /// </summary>
-    private sealed class NullEvaluatableExpressionFilter : EvaluatableExpressionFilterBase
+    private sealed class IgniteEvaluatableExpressionFilter : EvaluatableExpressionFilterBase
     {
-        // No-op.
+        // Ignores implicit ReadOnlySpan conversion to support C# 14 first class span Contains.
+        public override bool IsEvaluatableMethodCall(MethodCallExpression node)
+        {
+            ArgumentNullException.ThrowIfNull(node);
+            if (MemoryExtensionsContainsExpressionTransformer.IsSpanImplicitConversion(node))
+            {
+                return false;
+            }
+
+            return base.IsEvaluatableMethodCall(node);
+        }
+    }
+
+    /// <summary>
+    /// Implementation of IExpressionTransformer handling C# 14 first class span Contains.
+    /// </summary>
+    private sealed class MemoryExtensionsContainsExpressionTransformer : IExpressionTransformer<MethodCallExpression>
+    {
+        private static readonly MethodInfo SourceMethodInfo = typeof(MemoryExtensions)
+            .GetMethod(nameof(MemoryExtensions.Contains), [
+                typeof(ReadOnlySpan<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
+                Type.MakeGenericMethodParameter(0)
+            ])!;
+
+        private static readonly MethodInfo TargetMethodInfo = typeof(Enumerable)
+            .GetMethod(nameof(Enumerable.Contains), [
+                typeof(IEnumerable<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
+                Type.MakeGenericMethodParameter(0)
+            ])!;
+
+        public static bool IsSpanImplicitConversion([NotNullWhen(true)]MethodCallExpression? node) =>
+            node?.Method is { IsSpecialName: true, Name: "op_Implicit" }
+            && node.Method.DeclaringType is { IsGenericType: true }
+            && node.Method.DeclaringType.GetGenericTypeDefinition() == typeof(ReadOnlySpan<>);
+
+        public Expression Transform(MethodCallExpression expression)
+        {
+            if (expression.Method.IsConstructedGenericMethod && expression.Method.GetGenericMethodDefinition() == SourceMethodInfo)
+            {
+                var genericType = expression.Method.GetGenericArguments()[0];
+
+                var enumerableParameter = expression.Arguments[0] as MethodCallExpression;
+                if (!IsSpanImplicitConversion(enumerableParameter))
+                {
+                    throw new NotSupportedException("Was not able to process parameter for MemoryExtensions.Contains, " +
+                                                    "expected implicit conversion, got: " + expression.Arguments[0]);
+                }
+
+                var argument = enumerableParameter.Arguments[0]!;
+
+                var targetProp = expression.Arguments[1];
+
+                var target = TargetMethodInfo.MakeGenericMethod(genericType);
+                return Expression.Call(target, argument, targetProp);
+            }
+
+            return expression;
+        }
+
+#pragma warning disable CA1819
+#pragma warning disable SA1201
+        public ExpressionType[] SupportedExpressionTypes => [ExpressionType.Call];
+#pragma warning restore SA1201
+#pragma warning restore CA1819

Review Comment:
   The `SupportedExpressionTypes` property returns a new array each access and adds pragma suppressions (CA1819/SA1201) inline. Consider switching to a `static readonly ExpressionType[]` field and/or reordering members to avoid StyleCop suppressions and repeated allocations.



##########
modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.cs:
##########
@@ -158,6 +158,14 @@ public void TestSelectOrderByOffsetLimit() =>
                 .Take(3)
                 .ToList());
 
+    [Test]
+    public void TestContains() =>
+        AssertSql("select (_T0.KEY IN (?, ?)) from PUBLIC.TBL1 as _T0", q =>
+        {
+            var keys = new long[] { 4, 2 };
+            return q.Select(x => keys.Contains(x.Key)).ToList();
+        });

Review Comment:
   This test uses `keys.Contains(x.Key)` under the repo-wide `LangVersion=12`, where the call is expected to bind to `Enumerable.Contains` (not `MemoryExtensions.Contains`). As a result, it likely doesn't exercise the new `MemoryExtensionsContainsExpressionTransformer` / span implicit-conversion filter. Consider adding a test that explicitly builds (or forces) a `MemoryExtensions.Contains(ReadOnlySpan<T>, T)` call in the expression tree so the new code path is covered.



##########
modules/platforms/dotnet/Apache.Ignite/Internal/Linq/IgniteQueryParser.cs:
##########
@@ -17,8 +17,15 @@
 
 namespace Apache.Ignite.Internal.Linq;
 
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
 using System.Threading;
 using Dml;
+using Remotion.Linq.Clauses.Expressions;

Review Comment:
   `using Remotion.Linq.Clauses.Expressions;` appears to be unused in this file. With `TreatWarningsAsErrors=true`, this will fail the build with CS8019; please remove the unnecessary using directive.
   ```suggestion
   
   ```



##########
modules/platforms/dotnet/Apache.Ignite/Internal/Linq/IgniteQueryParser.cs:
##########
@@ -78,16 +86,79 @@ private static CompoundExpressionTreeProcessor CreateCompoundProcessor(
         return new CompoundExpressionTreeProcessor(
             new IExpressionTreeProcessor[]
             {
-                new PartialEvaluatingExpressionTreeProcessor(new NullEvaluatableExpressionFilter()),
+                new PartialEvaluatingExpressionTreeProcessor(new IgniteEvaluatableExpressionFilter()),
                 new TransformingExpressionTreeProcessor(transformationProvider)
             });
     }
 
     /// <summary>
-    /// Empty implementation of IEvaluatableExpressionFilter.
+    /// Implementation of IEvaluatableExpressionFilter.
     /// </summary>
-    private sealed class NullEvaluatableExpressionFilter : EvaluatableExpressionFilterBase
+    private sealed class IgniteEvaluatableExpressionFilter : EvaluatableExpressionFilterBase
     {
-        // No-op.
+        // Ignores implicit ReadOnlySpan conversion to support C# 14 first class span Contains.
+        public override bool IsEvaluatableMethodCall(MethodCallExpression node)
+        {
+            ArgumentNullException.ThrowIfNull(node);
+            if (MemoryExtensionsContainsExpressionTransformer.IsSpanImplicitConversion(node))
+            {
+                return false;
+            }
+
+            return base.IsEvaluatableMethodCall(node);
+        }
+    }
+
+    /// <summary>
+    /// Implementation of IExpressionTransformer handling C# 14 first class span Contains.
+    /// </summary>
+    private sealed class MemoryExtensionsContainsExpressionTransformer : IExpressionTransformer<MethodCallExpression>
+    {
+        private static readonly MethodInfo SourceMethodInfo = typeof(MemoryExtensions)
+            .GetMethod(nameof(MemoryExtensions.Contains), [
+                typeof(ReadOnlySpan<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
+                Type.MakeGenericMethodParameter(0)
+            ])!;
+
+        private static readonly MethodInfo TargetMethodInfo = typeof(Enumerable)
+            .GetMethod(nameof(Enumerable.Contains), [
+                typeof(IEnumerable<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
+                Type.MakeGenericMethodParameter(0)
+            ])!;
+
+        public static bool IsSpanImplicitConversion([NotNullWhen(true)]MethodCallExpression? node) =>
+            node?.Method is { IsSpecialName: true, Name: "op_Implicit" }
+            && node.Method.DeclaringType is { IsGenericType: true }
+            && node.Method.DeclaringType.GetGenericTypeDefinition() == typeof(ReadOnlySpan<>);
+
+        public Expression Transform(MethodCallExpression expression)
+        {
+            if (expression.Method.IsConstructedGenericMethod && expression.Method.GetGenericMethodDefinition() == SourceMethodInfo)
+            {
+                var genericType = expression.Method.GetGenericArguments()[0];
+
+                var enumerableParameter = expression.Arguments[0] as MethodCallExpression;
+                if (!IsSpanImplicitConversion(enumerableParameter))
+                {
+                    throw new NotSupportedException("Was not able to process parameter for MemoryExtensions.Contains, " +
+                                                    "expected implicit conversion, got: " + expression.Arguments[0]);
+                }
+
+                var argument = enumerableParameter.Arguments[0]!;
+
+                var targetProp = expression.Arguments[1];
+
+                var target = TargetMethodInfo.MakeGenericMethod(genericType);
+                return Expression.Call(target, argument, targetProp);

Review Comment:
   `targetProp` is a misleading name here: the expression represents the value being searched for (the second argument to `Contains`), not a property. Renaming it to something like `value`/`item` would make the transformation logic easier to follow.
   ```suggestion
                   var value = expression.Arguments[1];
   
                   var target = TargetMethodInfo.MakeGenericMethod(genericType);
                   return Expression.Call(target, argument, value);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27068 .NET: LINQ: Support C# 14 span methods [ignite-3]

Posted by "gurustron (via GitHub)" <gi...@apache.org>.
gurustron commented on code in PR #7933:
URL: https://github.com/apache/ignite-3/pull/7933#discussion_r3038394758


##########
modules/platforms/dotnet/Apache.Ignite/Internal/Linq/IgniteQueryParser.cs:
##########
@@ -78,16 +85,77 @@ private static CompoundExpressionTreeProcessor CreateCompoundProcessor(
         return new CompoundExpressionTreeProcessor(
             new IExpressionTreeProcessor[]
             {
-                new PartialEvaluatingExpressionTreeProcessor(new NullEvaluatableExpressionFilter()),
+                new PartialEvaluatingExpressionTreeProcessor(new IgniteEvaluatableExpressionFilter()),
                 new TransformingExpressionTreeProcessor(transformationProvider)
             });
     }
 
     /// <summary>
-    /// Empty implementation of IEvaluatableExpressionFilter.
+    /// Implementation of IEvaluatableExpressionFilter.
     /// </summary>
-    private sealed class NullEvaluatableExpressionFilter : EvaluatableExpressionFilterBase
+    private sealed class IgniteEvaluatableExpressionFilter : EvaluatableExpressionFilterBase
     {
-        // No-op.
+        // Ignores implicit ReadOnlySpan conversion to support C# 14 first class span Contains.
+        public override bool IsEvaluatableMethodCall(MethodCallExpression node)
+        {
+            ArgumentNullException.ThrowIfNull(node);
+            if (MemoryExtensionsContainsExpressionTransformer.IsSpanImplicitConversion(node))
+            {
+                return false;
+            }
+
+            return base.IsEvaluatableMethodCall(node);
+        }
+    }
+
+    /// <summary>
+    /// Implementation of IExpressionTransformer handling C# 14 first class span Contains.
+    /// </summary>
+    private sealed class MemoryExtensionsContainsExpressionTransformer : IExpressionTransformer<MethodCallExpression>
+    {
+        private static readonly MethodInfo SourceMethodInfo = typeof(MemoryExtensions)
+            .GetMethod(nameof(MemoryExtensions.Contains), [
+                typeof(ReadOnlySpan<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
+                Type.MakeGenericMethodParameter(0)
+            ])!;
+
+        private static readonly MethodInfo TargetMethodInfo = typeof(Enumerable)
+            .GetMethod(nameof(Enumerable.Contains), [
+                typeof(IEnumerable<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
+                Type.MakeGenericMethodParameter(0)
+            ])!;
+
+#pragma warning disable CA1819
+        public ExpressionType[] SupportedExpressionTypes => [ExpressionType.Call];
+#pragma warning restore CA1819
+
+        public static bool IsSpanImplicitConversion([NotNullWhen(true)]MethodCallExpression? node) =>
+            node?.Method is { IsSpecialName: true, Name: "op_Implicit" }
+            && node.Method.DeclaringType is { IsGenericType: true }
+            && node.Method.DeclaringType.GetGenericTypeDefinition() == typeof(ReadOnlySpan<>);
+
+        public Expression Transform(MethodCallExpression expression)
+        {
+            if (expression.Method.IsConstructedGenericMethod && expression.Method.GetGenericMethodDefinition() == SourceMethodInfo)

Review Comment:
   TBH I prefer this flow which covers "extraordinary" cases first, and in case of new ones it would be easier to add them.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27068 .NET: Thin 3.0: Support in LINQ C# 14 span methods [ignite-3]

Posted by "gurustron (via GitHub)" <gi...@apache.org>.
gurustron commented on code in PR #7933:
URL: https://github.com/apache/ignite-3/pull/7933#discussion_r3035603581


##########
modules/platforms/dotnet/Apache.Ignite/Internal/Linq/IgniteQueryParser.cs:
##########
@@ -17,8 +17,15 @@
 
 namespace Apache.Ignite.Internal.Linq;
 
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
 using System.Threading;
 using Dml;
+using Remotion.Linq.Clauses.Expressions;

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27068 .NET: LINQ: Support C# 14 span methods [ignite-3]

Posted by "gurustron (via GitHub)" <gi...@apache.org>.
gurustron merged PR #7933:
URL: https://github.com/apache/ignite-3/pull/7933


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27068 .NET: Thin 3.0: Support in LINQ C# 14 span methods [ignite-3]

Posted by "gurustron (via GitHub)" <gi...@apache.org>.
gurustron commented on PR #7933:
URL: https://github.com/apache/ignite-3/pull/7933#issuecomment-4187131954

   It is not possible to test this with .NET 8 SDK/runtime (C# 14 is needed). The added test does not actually do anything, testing was done in a separate branch with a separate project - https://github.com/gurustron/ignite-3/commit/8d6d21a20d83c73f13da08817d501896c9564786#diff-59756034c51e3f354b27eb11ce2a4611a1de92d3e29c726bebafc34114a31603


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org