Skip to content

Issue 12830 multi target demo console #12996

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

Merged

Conversation

ricardobossan
Copy link
Member

@ricardobossan ricardobossan commented Feb 21, 2025

Fixes #12830

Proposed changes

  • Updated DemoConsole.csproj and DesignSurfaceExt.csproj to support multiple target frameworks ($(NetCurrent)-windows;net481).
  • Adjusted TargetFramework property to avoid over-building.
  • Enabled SignAssembly and GenerateAssemblyInfo properties in the project files.
  • Updated resource and reference handling in DemoConsole.csproj and DesignSurfaceExt.csproj to improve compatibility.
  • Fixed Controls.AddRange usage to use the correct syntax in MainForm.MyUserControl.cs.
  • Corrected Controls.AddRange call in MainForm.cs to Controls.Add.
  • Suppressed IDE0057 warning and reverted to Substring method for compatibility in NameCreationServiceImp.cs.
  • Changed StartsWith('_') check by directly accessing the first character in NameCreationServiceImp.cs for compatibility.
  • Disabled error CA1824 for projects DemoConsole and DesignSurficeExt, because it would be triggered even though properly configured in those projects, according to the fix provided by the documentation.

Customer Impact

  • None

Regression?

  • No

Risk

  • Minimal

Screenshots

Before

  • DemoConsole would not run on net481.

After

image

Test methodology

  • Manual

Test environment(s)

  • 10.0.100-alpha.1.25077.2

@ricardobossan ricardobossan self-assigned this Feb 21, 2025
@ricardobossan
Copy link
Member Author

Drafted because:

  • Need to address nullability warnings
  • net481 compiles without errors but doesn't launch

@ricardobossan
Copy link
Member Author

ricardobossan commented Feb 21, 2025

@Tanya-Solyanik @LeafShi1 @Epica3055 I was able to get the DemoConsole project to compile for multiple targets ($(NetCurrent)-windows and net481), but it doesn't launch on net481. There's no error message explaining why. It just fails silently. Do you have any idea what might be causing this?

I’m aware of the nullability warnings that I still need to address, but could they be related to this issue?

@dotnet-policy-service dotnet-policy-service bot added the draft draft PR label Feb 21, 2025
Copy link
Contributor

@Tanya-Solyanik Tanya-Solyanik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enable all CLR exceptions before starting to debug this project as 4.8.1. I guess immutable collection reference is not discovered.

@ricardobossan ricardobossan force-pushed the Issue_12830_Multi-Target_DemoConsole branch from e1471f3 to 78c0cbd Compare February 21, 2025 18:03
@Tanya-Solyanik
Copy link
Contributor

@ricardobossan - the reason the NET481 version does not run is that the dll is not strong-name signed, we should delay-sign it. Arcade should have tools for that. Maybe like this <SignAssembly>true</SignAssembly> https://github.com/dotnet/arcade/blob/ecdb2f499cb5f5c99b58fba1a14fdf977c56e1ac/Documentation/ArcadeSdk.md?plain=1#L953
Search arcade docs to see if they recommend any signing test keys to use. We should not use a production key.

Copy link

codecov bot commented Feb 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.58708%. Comparing base (1d61434) to head (6f9ae8f).
Report is 52 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #12996         +/-   ##
===================================================
+ Coverage   62.19645%   62.58708%   +0.39063%     
===================================================
  Files           1556        1560          +4     
  Lines         159366      159763        +397     
  Branches       14854       14915         +61     
===================================================
+ Hits           99120       99991        +871     
+ Misses         59495       58996        -499     
- Partials         751         776         +25     
Flag Coverage Δ
Debug 62.58708% <ø> (+0.39063%) ⬆️
integration 11.32797% <ø> (+0.02738%) ⬆️
production 40.77070% <ø> (+0.43419%) ⬆️
test 95.69342% <ø> (+0.02618%) ⬆️
unit 38.15082% <ø> (+0.45840%) ⬆️

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ricardobossan ricardobossan marked this pull request as ready for review February 24, 2025 20:00
@ricardobossan ricardobossan requested a review from a team as a code owner February 24, 2025 20:00
@ricardobossan ricardobossan added waiting-review This item is waiting on review by one or more members of team and removed draft draft PR labels Feb 24, 2025
@LeafShi1
Copy link
Member

When using only net481 in the DemoConsole project, TabPage6 does not display properly. When enabling all CLR exceptions before starting to debug this project, I receive the following error

image

@ricardobossan
Copy link
Member Author

@LeafShi1 I was able to run the project and navigate through the tabs on net481 with all CLR exceptions enabled, as shown in the GIF below:

clr exceptions enabled net481 works

Here’s how I set up and ran the project:

# From the runtime repo root folder:
gh pr checkout 12996
msbuild /t:Clean .\Winforms.sln
.\Restore.cmd
.\build.cmd
.\start-vs.cmd

Could you share the exact steps you're using to run the project? That might help pinpoint any differences that could explain the discrepancy in our results.

@LeafShi1
Copy link
Member

Could you share the exact steps you're using to run the project? That might help pinpoint any differences that could explain the discrepancy in our results.

When using <TargetFrameworks>$(NetCurrent)-windows;net481</TargetFrameworks>, it shows up fine on my end。
I just tried changing the TargetFramework to net481, like this
image

But it doesn't seem to work, because it causes compilation to fail

So please ignore my comment

@Tanya-Solyanik Tanya-Solyanik added waiting-author-feedback The team requires more information from the author and removed waiting-review This item is waiting on review by one or more members of team labels Feb 26, 2025
ricardobossan pushed a commit to ricardobossan/winforms that referenced this pull request Feb 28, 2025
…e everything visible in the surface designer.

Related dotnet#12996

- Resizes `DemoConsole` project's `MainForm` for convenience and to make everything visible in the surface designer.

- None

- No

- Minimal

- Manual

- 10.0.100-preview.3.25125.5
@ricardobossan ricardobossan added waiting-review This item is waiting on review by one or more members of team and removed waiting-author-feedback The team requires more information from the author labels Mar 3, 2025
@Epica3055 Epica3055 force-pushed the Issue_12830_Multi-Target_DemoConsole branch from 0f2bd56 to 1c60128 Compare April 15, 2025 08:07
@ricardobossan ricardobossan force-pushed the Issue_12830_Multi-Target_DemoConsole branch from 1c60128 to 8794666 Compare April 15, 2025 19:25
Fixes dotnet#12830

- Updated `DemoConsole.csproj` and `DesignSurfaceExt.csproj` to support multiple target frameworks (`$(NetCurrent)-windows;net481`).
- Adjusted `TargetFramework` property to avoid over-building.
- Enabled `SignAssembly` and `GenerateAssemblyInfo` properties in the project files.
- Updated resource and reference handling in `DemoConsole.csproj` and `DesignSurfaceExt.csproj` to improve compatibility.
- Fixed `Controls.AddRange` usage to use the correct syntax in `MainForm.MyUserControl.cs`.
- Corrected `Controls.AddRange` call in `MainForm.cs` to `Controls.Add`.
- Suppressed `IDE0057` warning and reverted to `Substring` method for compatibility in `NameCreationServiceImp.cs`.
- Changed `StartsWith('_')` check by directly accessing the first character in `NameCreationServiceImp.cs` for compatibility.
- Disabled error `CA1824` for projects `DemoConsole` and `DesignSurficeExt`, because it would be triggered even though properly configured in those projects, according to the fix provided by the [documentation](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1824#fix-violations).

- None

- No

- Minimal

- `DemoConsole` would not run on `net481`.

- Manual

- 10.0.100-preview.3.25125.5
@ricardobossan ricardobossan force-pushed the Issue_12830_Multi-Target_DemoConsole branch from 8794666 to 735ca00 Compare April 15, 2025 22:04
@Tanya-Solyanik
Copy link
Contributor

@ricardobossan - if System.Runtime.CompilerServices.Unsafe is not available, it's ok to keep targeting 481. I'm curious, what version of compiler services is 481 using?

Ricardo Bossan (BEYONDSOFT CONSULTING INC) added 2 commits April 16, 2025 15:00
@ricardobossan ricardobossan marked this pull request as ready for review April 16, 2025 21:33
@ricardobossan ricardobossan added waiting-review This item is waiting on review by one or more members of team and removed draft draft PR waiting-review This item is waiting on review by one or more members of team labels Apr 16, 2025
@ricardobossan ricardobossan added the waiting-review This item is waiting on review by one or more members of team label Apr 16, 2025
@ricardobossan
Copy link
Member Author

@ricardobossan - if System.Runtime.CompilerServices.Unsafe is not available, it's ok to keep targeting 481. I'm curious, what version of compiler services is 481 using?

Looks like it's pulling in version 6.1.0-preview.1.24511.1.

From eng/Versions.props:

<SystemRuntimeCompilerServicesUnsafePackageVersion>6.1.0-preview.1.24511.1</SystemRuntimeCompilerServicesUnsafePackageVersion>

And confirmed in DemoConsole's project.assets.json, line 3091:

"System.Runtime.CompilerServices.Unsafe": "6.1.0-preview.1.24511.1"

@Tanya-Solyanik
Copy link
Contributor

build failure is a dupe of #13291

LeafShi1
LeafShi1 previously approved these changes Apr 23, 2025
Copy link
Member

@LeafShi1 LeafShi1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a few comment

…ext PR

2. set main form name so that it reflects the target framework.
3. show readme.md in the solution explorer.
4. removed a default constructor, it will be generated for us.
5. it's ok to have lines almost 120 chars long
@Tanya-Solyanik
Copy link
Contributor

@LeafShi1 @ricardobossan - I had experimented with the solution explorer view a little and pushed by feedback into this branch as a commit, please review it and if it looks ok, merge this PR. Test team can test it after it's merged.

@ricardobossan ricardobossan merged commit 3312c70 into dotnet:main Apr 24, 2025
8 checks passed
@dotnet-policy-service dotnet-policy-service bot removed the waiting-review This item is waiting on review by one or more members of team label Apr 24, 2025
@@ -19,21 +19,13 @@
avoid over-building. -->
<TargetFramework />

<DefaultItemExcludes Condition="'$(TargetFramework)' != 'net481'">
$(DefaultItemExcludes);**/Framework/*</DefaultItemExcludes>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ricardobossan - please move these exclusions to the next PR

@github-actions github-actions bot locked and limited conversation to collaborators May 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make the DemoConsole application multi-targeted to both .NET and .NET Framework
4 participants