Skip to content

INTL0202: Add binary operation detection for DateTime/DateTimeOffset conversions#369

Merged
BenjaminMichaelis merged 1 commit intomainfrom
copilot/fix-intl0202-lambda-conversion
Mar 10, 2026
Merged

INTL0202: Add binary operation detection for DateTime/DateTimeOffset conversions#369
BenjaminMichaelis merged 1 commit intomainfrom
copilot/fix-intl0202-lambda-conversion

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

Plan to fix INTL0202 detection in lambda functions

  • Understand the issue: INTL0202 not triggering for DateTime to DateTimeOffset conversions in lambda functions
  • Explore repository structure and build system
  • Run existing tests to establish baseline
  • Add test cases to validate different scenarios
  • Analyze why current analyzer misses conversions
  • Implement binary operation handler for type-based detection
  • Add nullable type unwrapping
  • Address PR review feedback (throw exceptions for missing types)
  • Restore tests with [Ignore] attribute for unimplemented scenarios
  • All tests passing (76 passed, 4 skipped)

Current Status

Working ✅:

  • Variable comparisons (DateTime dt < DateTimeOffset dto)
  • Direct assignments (DateTimeOffset x = DateTime.Now)
  • Nullable variable comparisons
  • Basic lambda expressions with variables

Not Yet Implemented (Tests Skipped):

  • Property-based comparisons (pair.DateTime < pair.DateTimeOffset)
  • Property access in LINQ expressions
  • Original issue scenario with .Date property chains

Root Cause: Roslyn does not create standard IConversionOperation nodes for property access in binary operations. Additional investigation is needed to determine the correct approach.

Test Status:

  • ✅ All 80 analyzer tests accounted for: 76 passed, 4 skipped
  • Tests for unimplemented property-based scenarios marked with [Ignore] attribute instead of deleted
  • Preserves test cases for future implementation

Note: Rebase onto main is pending due to merge conflicts with PR #368 which modified the same analyzer file. Manual merge required to combine both implementations.

Next Steps: Property-based conversion detection requires deeper investigation of Roslyn's IOperation tree structure for property access scenarios.

Original prompt

This section details on the original issue you should resolve

<issue_title>INTL0202 when conversion in lambda func</issue_title>
<issue_description>I would expect INTL0202 to be triggered here:

image
public override IQueryable<TimeEntry> GetQuery(IDataSourceParameters parameters)
{
    var query = Db.TimeEntries
    .Where(te =>
    te. EndDate <= EndDate.Date.AddDays(1).AddTicks(-1) &&
    te. StartDate > StartDate.Date

See also https://github.com/IntelliTect-dev/StormingTheCastle/issues/2139#issuecomment-1881630056</issue_description>

<agent_instructions>https://github.com/IntelliTect/CodingGuidelines/pull/255/changes</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Loading
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.

INTL0202 when conversion in lambda func

3 participants