dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.35k stars 965 forks source link

Testing WinForms VB Code Issue #11031

Open paul1956 opened 6 months ago

paul1956 commented 6 months ago

Background and motivation

I would like to write some test for WinForms Code written in VB in Project Microsoft.VisualBasic.Forms but many functions I want to test are not visible to testing. In C# they are declared with an attribute similar to [assembly:InternalsVisibleTo("NameOfYourUnitTestProject")], But I don't know how to do that for the VB functions.

API Proposal

Make Microsoft.VisualBasic.Forms functions InternalsVisibleTo test functions

API Usage

Not sure

Alternative Designs

Don't test VB internals as it is today with <30% coverage

Risks

If I do it high, if someone that knows what they are doing does it none.

Will this feature affect UI controls?

No

JeremyKuhne commented 5 months ago

@KlausLoeffelmann can you add the visibility attribute for these?

KlausLoeffelmann commented 4 days ago

In C# they are declared with an attribute similar to [assembly:InternalsVisibleTo("NameOfYourUnitTestProject")], But I don't know how to do that for the VB functions.

@paul1956 : What assembly do you need exactly to call from the tests?

paul1956 commented 4 days ago

@KlausLoeffelmann I added below in one of my PR's early on, but feedback was not to do it that way. Since I had no other way I left the PR open and posted this issue.

<Assembly: InternalsVisibleTo("Microsoft.VisualBasic.Forms.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")>

There is a test to verify the PublicKey.

KlausLoeffelmann commented 3 days ago

You wanted to put this where and what did you need to call?

paul1956 commented 3 days ago

@KlausLoeffelmann image