dotnet / dotnet/winforms

Allow internal types to be selected as object data source for binding

Open
#11,408 4 comments 0 reactions 1 assignee Claimed by @KlausLoeffelmann View on GitHub
area-Binding area-VSDesigner
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
1d 13m
Merged PRs (30d)
85

Description

### Environment

Microsoft Visual Studio Enterprise 2022 (64-bit) - Version 17.9.6

### .NET version

.NET 8

### Did this work in a previous version of Visual Studio and/or previous .NET release?

Nope

### Issue description

We are unable to select internal types as a `DataSource` for binding. Our company policy is to have all non-customer-facing public APIs set to internal and make them internally available within the company using the `InternalsVisibleTo` project element.

As a current workaround, we temporarily set the access modifier of the classes to `public`, and then revert them back to `internal` after selecting the type in question. However, this can become cumbersome with larger view models that have multiple layers of `internal` classes, where the `public` modifier has to cascade to every dependency.

### Steps to reproduce

1. Create a new .NET 8 WinForms project
2. Create a `internal` class with a `public` property for data binding
3. Add a control to the Form supporting data binding
4. Attempt to set the `DataSource` (or `DataContext`) of the control to the `internal` class using the "Add and update object data sources" tool
5. Observe an empty list

### Diagnostics

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.