Skip to content
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

A casting issue error is thrown when passing ObjectCollection to the AddRangeInternal method of the DataGridViewComboBoxCell.ObjectCollection class. #12612

Closed
ricardobossan opened this issue Dec 9, 2024 · 2 comments · Fixed by #12613 or #12685
Assignees
Labels
💥 regression-release Regression from a public release 🚧 work in progress Work that is current in progress

Comments

@ricardobossan
Copy link
Member

.NET version

10.0.100-alpha.1.24573.1

Did it work in .NET Framework?

Not tested/verified

Did it work in any of the earlier releases of .NET Core or .NET 5+?

No response

Issue description

A casting issue error is thrown when passing ObjectCollection to the AddRangeInternal method of the DataGridViewComboBoxCell.ObjectCollection class.

Steps to reproduce

  • Add a unit test for DataGridViewComboBoxCell.ObjectCollection class's AddRange(ObjectCollection value):

    [WinFormsFact]
    public void ObjectCollection_AddRange_AddsItemsCorrectly()
    {
       DataGridViewComboBoxCell comboBoxCell = new();
       DataGridViewComboBoxCell.ObjectCollection collection = new(comboBoxCell);
       DataGridViewComboBoxCell.ObjectCollection items = new(comboBoxCell) { "Item1", "Item2", "Item3" };
    
       collection.AddRange(items);
    
       collection.Count.Should().Be(3);
       collection[0].Should().Be("Item1");
       collection[1].Should().Be("Item2");
       collection[2].Should().Be("Item3");
    }
  • Debug test:

Image

@ricardobossan ricardobossan added untriaged The team needs to look at this issue in the next triage and removed untriaged The team needs to look at this issue in the next triage labels Dec 9, 2024
@ricardobossan ricardobossan self-assigned this Dec 9, 2024
ricardobossan pushed a commit to ricardobossan/winforms that referenced this issue Dec 9, 2024
…g `ObjectCollection` to `AddRangeInternal` of the `DataGridViewComboBoxCell.ObjectCollection` class

Fixes dotnet#12612

## Proposed changes

- Avoids a `System.InvalidCastException` error to be thrown when passing
`ObjectCollection` to `AddRangeInternal` of the
`DataGridViewComboBoxCell.ObjectCollection` class, by:
  - Modifying the `AddRange(ObjectCollection value)` method
  - Adding the `AddRangeInternal(ObjectCollection items)` methods
- Adds unit test

## Customer Impact

- Avoids a possible `System.InvalidCastException`

## Regression?

- No

## Risk

- Minimal

## Screenshots

### Before

### After

## Test methodology

- Unit tests

## Accessibility testing

## Test environment(s)

- `10.0.100-alpha.1.24573.1`
@dotnet-policy-service dotnet-policy-service bot added the 🚧 work in progress Work that is current in progress label Dec 9, 2024
ricardobossan pushed a commit to ricardobossan/winforms that referenced this issue Dec 10, 2024
…g `ObjectCollection` to `AddRangeInternal` of the `DataGridViewComboBoxCell.ObjectCollection` class

Fixes dotnet#12612

## Proposed changes

- Avoids a `System.InvalidCastException` error to be thrown when passing
`ObjectCollection` to `AddRangeInternal` of the
`DataGridViewComboBoxCell.ObjectCollection` class, by:
  - Modifying the `AddRange(ObjectCollection value)` method
  - Adding the `AddRangeInternal(ObjectCollection items)` methods
- Adds unit test

## Customer Impact

- Avoids a possible `System.InvalidCastException`

## Regression?

- No

## Risk

- Minimal

## Screenshots

### Before

![Captura de tela 2024-12-09
200542](https://github.com/user-attachments/assets/c5b9fa72-cb93-4c67-b17e-9ffb88a3fa0d)

### After

![image](https://github.com/user-attachments/assets/bc52a015-79f0-40e3-b4e5-0b2b3d095893)

## Test methodology

- Unit tests

## Accessibility testing

## Test environment(s)

- `10.0.100-alpha.1.24573.1`

 ###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/winforms/pull/12613)
ricardobossan pushed a commit to ricardobossan/winforms that referenced this issue Dec 11, 2024
…g `ObjectCollection` to `AddRangeInternal` of the `DataGridViewComboBoxCell.ObjectCollection` class

Fixes dotnet#12612

- Avoids a `System.InvalidCastException` error to be thrown when passing
`ObjectCollection` to `AddRangeInternal` of the
`DataGridViewComboBoxCell.ObjectCollection` class, by:
  - Modifying the `AddRange(ObjectCollection value)` method
  - Adding the `AddRangeInternal(ObjectCollection items)` methods
- Adds unit test

- Avoids a possible `System.InvalidCastException`

- No

- Minimal

![Captura de tela 2024-12-09
200542](https://github.com/user-attachments/assets/c5b9fa72-cb93-4c67-b17e-9ffb88a3fa0d)

![image](https://github.com/user-attachments/assets/bc52a015-79f0-40e3-b4e5-0b2b3d095893)

- Unit tests

- `10.0.100-alpha.1.24573.1`

 ###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/winforms/pull/12613)
@Tanya-Solyanik
Copy link
Member

Introduced in commit 2a92763

@Tanya-Solyanik Tanya-Solyanik added the 💥 regression-release Regression from a public release label Dec 18, 2024
@Tanya-Solyanik
Copy link
Member

We decided to not service this issue right now, but we will revisit this decision if we get more reports.

ricardobossan pushed a commit to ricardobossan/winforms that referenced this issue Dec 18, 2024
…ObjectCollection to AddRangeInternal of the DataGridViewComboBoxCell.ObjectCollection

Fixes dotnet#12612

## Proposed changes

- Avoids a `System.InvalidCastException` error to be thrown when passing
`ObjectCollection` to `AddRangeInternal` of the
`DataGridViewComboBoxCell.ObjectCollection` class, by:
  - Modifying the `AddRange(ObjectCollection value)` method
  - Adding the `AddRangeInternal(ObjectCollection items)` methods
- Adds unit test

## Customer Impact

- Avoids a possible `System.InvalidCastException`

## Regression?

- No

## Risk

- Minimal

## Screenshots

### Before

### After

## Test methodology

- Unit tests

## Accessibility testing

## Test environment(s)

- `10.0.100-alpha.1.24573.1`
lonitra pushed a commit that referenced this issue Dec 19, 2024
…g `ObjectCollection` to `AddRangeInternal` of the `DataGridViewComboBoxCell.ObjectCollection` class (#12613)

Avoids a System.InvalidCastException error to be thrown when passing ObjectCollection to AddRangeInternal of the DataGridViewComboBoxCell.ObjectCollection

Fixes #12612

## Proposed changes

- Avoids a `System.InvalidCastException` error to be thrown when passing
`ObjectCollection` to `AddRangeInternal` of the
`DataGridViewComboBoxCell.ObjectCollection` class, by:
  - Modifying the `AddRange(ObjectCollection value)` method
  - Adding the `AddRangeInternal(ObjectCollection items)` methods
- Adds unit test

## Customer Impact

- Avoids a possible `System.InvalidCastException`

## Regression?

- No

## Risk

- Minimal

## Screenshots

### Before

### After

## Test methodology

- Unit tests

## Accessibility testing

## Test environment(s)

- `10.0.100-alpha.1.24573.1`

Co-authored-by: Ricardo Bossan (BEYONDSOFT CONSULTING INC) (from Dev Box) <v-rbossan@microsoft.com>
ricardobossan pushed a commit to ricardobossan/winforms that referenced this issue Dec 26, 2024
Fixes dotnet#12612
Related dotnet#12613

## Root Cause

- A `[WinFormsFact]` annotation was missing from a unit test in PR
dotnet#12613, causing the test not to execute as part of the suite.

## Proposed changes

- Add the missing `[WinFormsFact]` annotation to the relevant unit test.

## Customer Impact

- Ensures the test runs as intended, increasing coverage and preventing
regressions in the modified `DataGridViewComboBoxCell.ObjectCollection`
class.

## Regression?

- No

## Risk

- Minimal

## Test methodology

- Unit tests

## Test environment(s)

- 10.0.100-alpha.1.24573.1
LeafShi1 pushed a commit that referenced this issue Dec 27, 2024
…12685)

Fixes #12612
Related #12613

## Root Cause

- A `[WinFormsFact]` annotation was missing from a unit test in PR
#12613, causing the test not to execute as part of the suite.

## Proposed changes

- Add the missing `[WinFormsFact]` annotation to the relevant unit test.

## Customer Impact

- Ensures the test runs as intended, increasing coverage and preventing
regressions in the modified `DataGridViewComboBoxCell.ObjectCollection`
class.

## Regression?

- No

## Risk

- Minimal

## Test methodology

- Unit tests

## Test environment(s)

- 10.0.100-alpha.1.24573.1

Co-authored-by: Ricardo Bossan (BEYONDSOFT CONSULTING INC) (from Dev Box) <v-rbossan@microsoft.com>
@github-actions github-actions bot locked and limited conversation to collaborators Jan 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.