-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Issue 12830 multi target demo console #12996
base: main
Are you sure you want to change the base?
Issue 12830 multi target demo console #12996
Conversation
Drafted because:
|
@Tanya-Solyanik @LeafShi1 @Epica3055 I was able to get the I’m aware of the nullability warnings that I still need to address, but could they be related to this issue? |
There was a problem hiding this 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.
src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/DemoConsole.csproj
Show resolved
Hide resolved
src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/DemoConsole.csproj
Outdated
Show resolved
Hide resolved
<ItemGroup> | ||
<EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" /> | ||
<Compile Update="Properties\Resources.Designer.cs" AutoGen="True" DependentUpon="Resources.resx" DesignTime="True" /> | ||
<PackageReference Include="System.Resources.Extensions" VersionOverride="5.0.0"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this is needed now, we were building resources for Core correctly before this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is necessary to avoid this build error when building from DemoConsole
:
# On `DemoConsole` folder:
dotnet restore
msbuild /t:Clean DemoConsole.csproj
msbuild
output:
C:\Program Files\dotnet\sdk\10.0.100-preview.2.25117.4\Microsoft.Common.CurrentVersion.targets(3426,5): error MSB3822: Non-string resources require the System.Resources.Extensions assembly at runtime, but it was not found in this project's references.
However, this error doesn't show when building from the solution's root folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not hard code package versions, are we not getting this version automatically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This package reference and version is set both in eng/Versions.props
and in Directory.Packages.props
. However, the build fails for net481:
System.Windows.Forms.PrivateSourceGenerators succeeded (6.5s) → artifacts\bin\System.Windows.Forms.PrivateSourceGenerators\Debug\netstandard2.0\System.Windows.Forms.PrivateSourceGenerators.dll
DemoConsole net481 failed with 1 error(s) (0.5s)
To remedy that, first I tried override the package specifically in DemoConsole.csproj
.
I'll condition it to net481, since it's the only affected version.
@@ -37,6 +40,7 @@ protected override void Dispose(bool disposing) | |||
base.Dispose(disposing); | |||
} | |||
|
|||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change can be factored out into a separate PR with some other cleanup changes you have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is necessary to prevent the following build error, which occurs regardless of whether the solution is built from the root or the DemoConsole
folder:
"C:\Users\v-rbossan\source\repos\winforms\Winforms.sln" (default target) (1) ->
"C:\Users\v-rbossan\source\repos\winforms\src\System.Windows.Forms\tests\IntegrationTests\DesignSurface\DemoConsole\DemoConsole.csproj" (default target) (42) ->
"C:\Users\v-rbossan\source\repos\winforms\src\System.Windows.Forms\tests\IntegrationTests\DesignSurface\DemoConsole\DemoConsole.csproj" (Build target) (42:2) ->
"C:\Users\v-rbossan\source\repos\winforms\src\System.Windows.Forms\tests\IntegrationTests\DesignSurface\DesignSurfaceExt\DesignSurfaceExt.csproj" (default target) (43:4) ->
(CoreCompile target) ->
C:\Users\v-rbossan\source\repos\winforms\src\System.Windows.Forms\tests\IntegrationTests\DesignSurface\DesignSurfaceExt\PropertyGridExt.cs(43,26): error WFO1000: Property 'DesignerHost' does not configur
e the code serialization for its property content [C:\Users\v-rbossan\source\repos\winforms\src\System.Windows.Forms\tests\IntegrationTests\DesignSurface\DesignSurfaceExt\DesignSurfaceExt.csproj::TargetFra
mework=net10.0-windows]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this change is necessary, I suggest getting it in before the rest of the changes in this PR to make this PR more targetted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed that change and this time was able to build without errors.
Should I still create a PR for it regardless?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e1471f3
to
78c0cbd
Compare
src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/DemoConsole.csproj
Outdated
Show resolved
Hide resolved
@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 |
…lizationVisibility annotatino from DesignerHost
…ystem.Collections.Immutable, in the DesignSurfaceExt project
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #12996 +/- ##
===================================================
+ Coverage 76.01028% 76.09601% +0.08573%
===================================================
Files 3267 3272 +5
Lines 643459 643700 +241
Branches 47432 47438 +6
===================================================
+ Hits 489095 489830 +735
+ Misses 150791 150306 -485
+ Partials 3573 3564 -9
Flags with carried forward coverage won't be shown. Click here to find out more. |
@LeafShi1 I was able to run the project and navigate through the tabs on 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. |
<ImplicitUsings>enable</ImplicitUsings> | ||
<SignAssembly>true</SignAssembly> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this property on .NET Core, we should include it conditionally.
Language version is already set to latest for Core.
|
||
<!-- Do not build this project when doing a .NET product build. --> | ||
<!-- The files for this project have been removed from the .NET product due to licensing issues. --> | ||
<ExcludeFromDotNetBuild>true</ExcludeFromDotNetBuild> | ||
<IsTestUtilityProject>true</IsTestUtilityProject> | ||
<TargetFrameworks>$(NetCurrent)-windows;net481</TargetFrameworks> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most new and some old properties are shared between DemoConsole and the DesignSurfaceExt projects, you can factor them out into Directory.Build.props file in the DesignSurface folder. It will be easier to update them in a single place in the future.
|
||
<ItemGroup Condition="'$(TargetFramework)' == '$(NetCurrent)-windows'"> | ||
<ProjectReference Include="..\..\..\..\..\System.Design\src\System.Design.Facade.csproj" /> | ||
<ProjectReference Include="..\..\..\..\..\System.Drawing.Design\src\System.Drawing.Design.Facade.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think facade assemblies are required here as we reference them in the DesignSurfaceExt.csproj
@@ -32,7 +33,9 @@ public string CreateName(IContainer container, Type type) | |||
count++; | |||
try | |||
{ | |||
int value = int.Parse(name[type.Name.Length..]); | |||
#pragma warning disable IDE0057 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the comment that describes this rule (the one that the codefix adds) to line 36. And also mention that the reason we suppress it is that the Range is not available on .NET Framework. Alternatively, you can use Range when compiling for Core only, i.e. use #if NETCOREAPP
<ItemGroup> | ||
<EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" /> | ||
<Compile Update="Properties\Resources.Designer.cs" AutoGen="True" DependentUpon="Resources.resx" DesignTime="True" /> | ||
<PackageReference Include="System.Resources.Extensions" VersionOverride="5.0.0"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not hard code package versions, are we not getting this version automatically?
<Copyright>Copyright © Paolo Foti 2008</Copyright> | ||
<Company /> | ||
<Authors>Paolo Foti</Authors> | ||
<PackageLicenseExpression>CPOL</PackageLicenseExpression> | ||
<PackageProjectUrl>https://www.codeproject.com/Articles/24385/Have-a-Great-DesignTime-Experience-with-a-Powerful</PackageProjectUrl> | ||
<SuppressLicenseValidation>true</SuppressLicenseValidation> | ||
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization> | ||
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources> | ||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this one is needed for the .NET Framework case only
<ProjectReference Include="..\..\..\..\..\System.Design\src\System.Design.Facade.csproj" /> | ||
<ProjectReference Include="..\..\..\..\..\System.Drawing.Design\src\System.Drawing.Design.Facade.csproj" /> | ||
<ProjectReference Include="..\..\..\..\..\System.Windows.Forms.Design\src\System.Windows.Forms.Design.csproj" /> | ||
<ProjectReference Include="..\..\..\..\src\System.Windows.Forms.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(TargetFramework)' == 'net481'"> | ||
<PackageReference Include="System.Collections.Immutable" VersionOverride="9.0.2" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to move this version to versions.props?
Fixes #12830
Proposed changes
DemoConsole.csproj
andDesignSurfaceExt.csproj
to support multiple target frameworks ($(NetCurrent)-windows;net481
).TargetFramework
property to avoid over-building.SignAssembly
andGenerateAssemblyInfo
properties in the project files.DemoConsole.csproj
andDesignSurfaceExt.csproj
to improve compatibility.Controls.AddRange
usage to use the correct syntax inMainForm.MyUserControl.cs
.Controls.AddRange
call inMainForm.cs
toControls.Add
.IDE0057
warning and reverted toSubstring
method for compatibility inNameCreationServiceImp.cs
.StartsWith('_')
check by directly accessing the first character inNameCreationServiceImp.cs
for compatibility.CA1824
for projectsDemoConsole
andDesignSurficeExt
, because it would be triggered even though properly configured in those projects, according to the fix provided by the documentation.Customer Impact
Regression?
Risk
Screenshots
Before
DemoConsole
would not run onnet481
.After
Test methodology
Test environment(s)