Skip to content

Conversation

@leminh98
Copy link
Contributor

@leminh98 leminh98 commented Nov 6, 2025

Pull Request Template

Description

Please include a summary of the change and which issue is fixed. Include samples if adding new API, and include relevant motivation and context. List any dependencies that are required for this change.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [] This change requires a documentation update

Closing issues

To automatically close an issue: closes #IssueNumber

if (type == typeof(Enumerable) || type == typeof(Queryable) || type == typeof(CosmosLinq))

// Aside from the known types, we also need to avoid partial eval for op_implicit methods, which are the implicit conversions of enum to memoryextension span types (introduced in c#13)
if (type == typeof(Enumerable) || type == typeof(Queryable) || type == typeof(CosmosLinq) || methodCallExpression.Method.Name == "op_Implicit")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make the check tighter so that we only let through those on_implicit calls that we support.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a check that's broader than what we support, please add negative coverage for those cases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also guard consts (for downstream success).

&& methodCallExpression.Method.Name == "op_Implicit"
&& methodCallExpression.Method.DeclaringType is { IsGenericType: true } implicitCastDeclaringType
&& implicitCastDeclaringType.GetGenericTypeDefinition() is var genericTypeDefinition
&& (genericTypeDefinition == typeof(Span<>) || genericTypeDefinition == typeof(ReadOnlySpan<>)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug Assert inside if assuming this check is done at top level.

using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class Program
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename, turn this into a test project (if not already).

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Contributor

@adityasa adityasa Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename the project, class namespaces to something suitable that indicate these are .NET C#14 specific tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Microsoft.Azure.Cosmos.Tests.C14

}

ArrayContainsVisitor visitor = new ArrayContainsVisitor();
return visitor.VisitIN(searchExpression, (ConstantExpression)searchList, context);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ConstantExpression)searchList

Can we always guarantee this? Either we should assert before or do a check.

await container.CreateItemAsync(todoItem);
Console.WriteLine($"Created item: {todoItem.id}");

string[] someStringArray = ["Learn Cosmos DB"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

["Learn Cosmos DB"]

Can you add a test variation with non-constant array?

<EmulatorFlavor>master</EmulatorFlavor>
<DisableCopyEmulator>True</DisableCopyEmulator>
<LangVersion>$(LangVersion)</LangVersion>
<LangVersion>preview</LangVersion>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert.

<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Platform>AnyCPU</Platform>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert.

List<LinqTestInput> inputs = new List<LinqTestInput>
{
{
//// Memory Span Conversion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert.

Type type = methodCallExpression.Method.DeclaringType;
if (type == typeof(Enumerable) || type == typeof(Queryable) || type == typeof(CosmosLinq))

// Aside from the known types, we also need to avoid partial eval for op_implicit methods, which are the implicit conversions of enum to memoryextension span types (introduced in c#13)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

13

14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants