Skip to content

Commit 78c0cbd

Browse files
author
Ricardo Bossan (BEYONDSOFT CONSULTING INC)
committed
Make DemoConsole multi-target
1 parent eedfdbe commit 78c0cbd

File tree

8 files changed

+66
-9
lines changed

8 files changed

+66
-9
lines changed

src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/DemoConsole.csproj

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,58 @@
1616
<PackageProjectUrl>https://www.codeproject.com/Articles/24385/Have-a-Great-DesignTime-Experience-with-a-Powerful</PackageProjectUrl>
1717
<SuppressLicenseValidation>true</SuppressLicenseValidation>
1818
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
19+
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
20+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
21+
1922

2023
<!-- Do not build this project when doing a .NET product build. -->
2124
<!-- The files for this project have been removed from the .NET product due to licensing issues. -->
2225
<ExcludeFromDotNetBuild>true</ExcludeFromDotNetBuild>
2326
<IsTestUtilityProject>true</IsTestUtilityProject>
27+
<TargetFrameworks>$(NetCurrent)-windows;net481</TargetFrameworks>
28+
<!-- Unset TargetFramework as this property gets set in Directory.Build.props. This is necessary to avoid over-building. -->
29+
<TargetFramework />
30+
31+
<Nullable>enable</Nullable>
32+
<UseWindowsForms>true</UseWindowsForms>
33+
<LangVersion>latest</LangVersion>
2434
<ImplicitUsings>enable</ImplicitUsings>
2535
</PropertyGroup>
2636

27-
<ItemGroup>
37+
<ItemGroup Condition="'$(TargetFramework)' == '$(NetCurrent)-windows'">
2838
<PackageReference Include="System.Runtime.Serialization.Formatters" />
2939
</ItemGroup>
3040

3141
<ItemGroup>
42+
<EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />
43+
<Compile Update="Properties\Resources.Designer.cs" AutoGen="True" DependentUpon="Resources.resx" DesignTime="True" />
44+
</ItemGroup>
45+
46+
<ItemGroup Condition="'$(TargetFramework)' == '$(NetCurrent)-windows'">
47+
<ProjectReference Include="..\..\..\..\..\System.Design\src\System.Design.Facade.csproj" />
48+
<ProjectReference Include="..\..\..\..\..\System.Drawing.Design\src\System.Drawing.Design.Facade.csproj" />
3249
<ProjectReference Include="..\..\..\..\..\System.Windows.Forms.Design\src\System.Windows.Forms.Design.csproj" />
3350
<ProjectReference Include="..\..\..\..\src\System.Windows.Forms.csproj" />
3451
<ProjectReference Include="..\..\..\..\..\System.Drawing.Common\src\System.Drawing.Common.csproj" />
52+
</ItemGroup>
53+
54+
<ItemGroup>
3555
<ProjectReference Include="..\DesignSurfaceExt\DesignSurfaceExt.csproj" />
3656
</ItemGroup>
3757

58+
<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
59+
<Reference Include='System.Windows.Forms'/>
60+
<Reference Include='System.Drawing'/>
61+
<Reference Include='System.Design'/>
62+
</ItemGroup>
63+
3864
<ItemGroup>
39-
<EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />
40-
<Compile Update="Properties\Resources.Designer.cs" AutoGen="True" DependentUpon="Resources.resx" DesignTime="True" />
65+
<PackageReference Include="System.Resources.Extensions" VersionOverride="5.0.0"/>
4166
</ItemGroup>
4267

4368
<ItemGroup>
4469
<None Update="painter.ico">
4570
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
4671
</None>
4772
</ItemGroup>
48-
4973
</Project>

src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/GlobalUsings.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,11 @@
88
global using System.ComponentModel.Design;
99
global using System.Windows.Forms.Design;
1010
global using DesignSurfaceExt;
11+
global using System.Diagnostics;
1112
global using Timer = System.Windows.Forms.Timer;
13+
14+
#if NETFRAMEWORK
15+
global using System.Drawing;
16+
global using System.Windows.Forms;
17+
#endif
18+

src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.MyUserControl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void InitializeComponent()
4040
Size = new(30, 30)
4141
};
4242

43-
Controls.AddRange(textBox2, textBox1, textBox);
43+
Controls.AddRange([textBox2, textBox1, textBox]);
4444
}
4545
}
4646
}

src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ private void CreateDesignSurface(int n)
341341
splitterPanel1.Controls.Add(richTextBox);
342342
splitterPanel2.Controls.Add(scrollableControl);
343343

344-
toolStripContainer.ContentPanel.Controls.AddRange(splitContainer);
344+
toolStripContainer.ContentPanel.Controls.Add(splitContainer);
345345

346346
Component component = surface.CreateComponent<Component>();
347347

src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DesignSurfaceExt/DesignSurfaceExt.csproj

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<UpdateXlfOnBuild>false</UpdateXlfOnBuild>
88
<ApplicationIcon>dll.ico</ApplicationIcon>
99
<SignAssembly>false</SignAssembly>
10+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1011

1112
<NoWarn>$(NoWarn),SA1633</NoWarn>
1213
<Copyright>Copyright © Paolo Foti 2008</Copyright>
@@ -21,14 +22,29 @@
2122
<!-- The files for this project have been removed from the .NET product due to licensing issues. -->
2223
<ExcludeFromDotNetBuild>true</ExcludeFromDotNetBuild>
2324
<IsTestUtilityProject>true</IsTestUtilityProject>
25+
<TargetFrameworks>$(NetCurrent)-windows;net481</TargetFrameworks>
26+
<!-- Unset TargetFramework as this property gets set in Directory.Build.props. This is necessary to avoid over-building. -->
27+
<TargetFramework />
28+
<UseWindowsForms>true</UseWindowsForms>
29+
30+
<LangVersion>latest</LangVersion>
2431
<ImplicitUsings>enable</ImplicitUsings>
2532
</PropertyGroup>
2633

27-
<ItemGroup>
34+
<ItemGroup Condition="'$(TargetFramework)' == '$(NetCurrent)-windows'">
2835
<ProjectReference Include="..\..\..\..\..\System.Design\src\System.Design.Facade.csproj" />
2936
<ProjectReference Include="..\..\..\..\..\System.Drawing.Design\src\System.Drawing.Design.Facade.csproj" />
3037
<ProjectReference Include="..\..\..\..\..\System.Windows.Forms.Design\src\System.Windows.Forms.Design.csproj" />
3138
<ProjectReference Include="..\..\..\..\src\System.Windows.Forms.csproj" />
3239
</ItemGroup>
40+
41+
<ItemGroup>
42+
<PackageReference Include="System.Collections.Immutable" VersionOverride="9.0.2" />
43+
</ItemGroup>
3344

45+
<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
46+
<Reference Include="System.Windows.Forms" />
47+
<Reference Include="System.Drawing" />
48+
<Reference Include="System.Design" />
49+
</ItemGroup>
3450
</Project>

src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DesignSurfaceExt/GlobalUsings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@
1111
global using System.Collections;
1212
global using System.Collections.Concurrent;
1313
global using System.Collections.Immutable;
14+
15+
#if NETFRAMEWORK
16+
global using System.Drawing;
17+
global using System.Windows.Forms;
18+
#endif
19+

src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DesignSurfaceExt/NameCreationServiceImp.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// - The INameCreationService interface is used to supply a name to the control just created
66
// - In the CreateName() we use the same naming algorithm used by Visual Studio: just
77
// - increment an integer counter until we find a name that isn't already in use.
8+
89
namespace DesignSurfaceExt;
910

1011
internal sealed class NameCreationServiceImp : INameCreationService
@@ -32,7 +33,9 @@ public string CreateName(IContainer container, Type type)
3233
count++;
3334
try
3435
{
35-
int value = int.Parse(name[type.Name.Length..]);
36+
#pragma warning disable IDE0057
37+
int value = int.Parse(name.Substring(type.Name.Length));
38+
#pragma warning disable IDE0057
3639
if (value < min)
3740
min = value;
3841
if (value > max)
@@ -72,7 +75,7 @@ public bool IsValidName(string name)
7275
return false;
7376

7477
// - then don't allow a leading underscore
75-
if (name.StartsWith('_'))
78+
if (name[0] == '_')
7679
return false;
7780

7881
// - ok, it's a valid name

src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DesignSurfaceExt/PropertyGridExt.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ protected override void Dispose(bool disposing)
3333
base.Dispose(disposing);
3434
}
3535

36+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3637
public IDesignerHost DesignerHost
3738
{
3839
get

0 commit comments

Comments
 (0)