Skip to content

Improve DataRow type mismatch error messages with descriptive parameter information #5819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 18, 2025

Summary

Improves the error message for DataRow type mismatches to provide clear, actionable information instead of confusing coordinate-like indices.

Problem

The current error message for DataRow type mismatches shows indices that look like coordinates, making it difficult for developers to understand what's wrong:

[DataRow("Luxury Car", "Alice Johnson", 1500.00, "https://example.com/luxurycar.jpg", "https://example.com/luxurycar")]
public void AddGift_ShouldRejectExpensiveGifts(string name, string reservedBy, decimal price, string imageUrl, string link)

Before: DataRow argument type should match method parameter type. Mismatches occur at indices: (2, 2)

This message is precise but unclear - it's not obvious that index 2 refers to the price parameter or that the issue is a double vs decimal type mismatch.

Solution

After: DataRow argument types do not match method parameter types. Parameter 'price' expects type 'decimal', but the provided value has type 'double'

This new message clearly identifies:

  • Which parameter has the issue (price)
  • What type is expected (decimal)
  • What type was actually provided (double)

Changes Made

  1. Updated error message format in Resources.resx and all localization files
  2. Modified analyzer logic in DataRowShouldBeValidAnalyzer.cs to:
    • Collect parameter names, expected types, and actual types instead of indices
    • Use ITypeSymbol.ToDisplayString() for readable type names
    • Report the first type mismatch with descriptive information
  3. Updated tests to expect the new message format
  4. Added new test specifically for the decimal/double scenario mentioned in the issue

Examples

Decimal vs Double (from issue)

[DataRow(1500.00)] // double literal
public void Test(decimal price) // decimal parameter

Error: Parameter 'price' expects type 'decimal', but the provided value has type 'double'

String vs Int

[DataRow(1, 2, 3)] // int literal
public void Test(int i, int j, string s) // string parameter

Error: Parameter 's' expects type 'string', but the provided value has type 'int'

Array Type Mismatch

[DataRow(1)] // int literal  
public void Test(object[] o) // array parameter

Error: Parameter 'o' expects type 'object[]', but the provided value has type 'int'

Fixes #4996

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 5rqvsblobprodcus385.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/testfx/testfx/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/testfx/testfx/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/testfx/testfx/artifacts/toolset/10.0.0-beta.25316.2.txt (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


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

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.47%. Comparing base (1dcce25) to head (7ebb077).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5819      +/-   ##
==========================================
+ Coverage   73.10%   73.47%   +0.37%     
==========================================
  Files         608      608              
  Lines       38370    37279    -1091     
==========================================
- Hits        28049    27390     -659     
+ Misses      10321     9889     -432     
Flag Coverage Δ
Debug 73.47% <0.00%> (+0.37%) ⬆️
integration 73.47% <0.00%> (+<0.01%) ⬆️
production 73.47% <0.00%> (+0.37%) ⬆️
unit 73.47% <0.00%> (+0.37%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 32 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Evangelink
Copy link
Member

Try again copilot please

Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Improve error message on data row mismatch Improve DataRow type mismatch error messages with descriptive parameter information Jun 19, 2025
Copilot finished work on behalf of Evangelink June 19, 2025 07:38
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.

Improve error message on data row mismatch
3 participants