Skip to content

Commit 29e6948

Browse files
author
Ricardo Bossan (BEYONDSOFT CONSULTING INC) (from Dev Box)
committed
Updated DemoConsole.csproj and DesignSurfaceExt.csproj to support multiple target frameworks ($(NetCurrent)-windows;net481).
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
1 parent de252e0 commit 29e6948

File tree

7 files changed

+73
-41
lines changed

7 files changed

+73
-41
lines changed

eng/Versions.props

+5
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,9 @@
114114
<!-- Pin transitive dependency to avoid vulnerable 8.0.0 version. -->
115115
<SystemFormatsAsn1PackageVersion>8.0.1</SystemFormatsAsn1PackageVersion>
116116
</PropertyGroup>
117+
118+
<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
119+
<PackageReference Include="System.Collections.Immutable" VersionOverride="9.0.2" />
120+
</ItemGroup>
121+
117122
</Project>

src/test/integration/DesignSurface/DemoConsole/DemoConsole.csproj

+8-19
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,33 @@
66
<ApplicationIcon>painter.ico</ApplicationIcon>
77
<OutputType>WinExe</OutputType>
88
<StartupObject />
9-
<EnableXlfLocalization>false</EnableXlfLocalization>
10-
<UpdateXlfOnBuild>false</UpdateXlfOnBuild>
11-
<NoWarn>$(NoWarn);SA1633;CS8002</NoWarn>
129
<Copyright>Copyright © Paolo Foti 2008</Copyright>
1310
<Company />
1411
<Authors>Paolo Foti</Authors>
12+
<NoWarn>$(NoWarn)CS8002;CA1824</NoWarn>
1513
<PackageLicenseExpression>CPOL</PackageLicenseExpression>
1614
<PackageProjectUrl>https://www.codeproject.com/Articles/24385/Have-a-Great-DesignTime-Experience-with-a-Powerful</PackageProjectUrl>
17-
<SuppressLicenseValidation>true</SuppressLicenseValidation>
1815
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
16+
</PropertyGroup>
1917

20-
<!-- Do not build this project when doing a .NET product build. -->
21-
<!-- The files for this project have been removed from the .NET product due to licensing issues. -->
22-
<ExcludeFromDotNetBuild>true</ExcludeFromDotNetBuild>
23-
<IsTestUtilityProject>true</IsTestUtilityProject>
24-
<ImplicitUsings>enable</ImplicitUsings>
18+
<PropertyGroup Condition="'$(TargetFramework)' == 'net481'">
19+
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
20+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
2521
</PropertyGroup>
2622

2723
<ItemGroup>
28-
<PackageReference Include="System.Runtime.Serialization.Formatters" />
24+
<EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />
25+
<Compile Update="Properties\Resources.Designer.cs" AutoGen="True" DependentUpon="Resources.resx" DesignTime="True" />
2926
</ItemGroup>
3027

3128
<ItemGroup>
32-
<ProjectReference Include="..\..\..\..\System.Drawing.Common\src\System.Drawing.Common.csproj" />
33-
<ProjectReference Include="..\..\..\..\System.Windows.Forms.Design\src\System.Windows.Forms.Design.csproj" />
34-
<ProjectReference Include="..\..\..\..\System.Windows.Forms\System.Windows.Forms.csproj" />
3529
<ProjectReference Include="..\DesignSurfaceExt\DesignSurfaceExt.csproj" />
3630
</ItemGroup>
3731

38-
<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" />
41-
</ItemGroup>
42-
4332
<ItemGroup>
4433
<None Update="painter.ico">
4534
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
4635
</None>
4736
</ItemGroup>
4837

49-
</Project>
38+
</Project>

src/test/integration/DesignSurface/DemoConsole/MainForm.MyUserControl.cs

+1-1
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/test/integration/DesignSurface/DemoConsole/MainForm.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ private void CreateDesignSurface(int n)
349349
splitterPanel1.Controls.Add(richTextBox);
350350
splitterPanel2.Controls.Add(scrollableControl);
351351

352-
toolStripContainer.ContentPanel.Controls.AddRange(splitContainer);
352+
toolStripContainer.ContentPanel.Controls.Add(splitContainer);
353353

354354
Component component = surface.CreateComponent<Component>();
355355

src/test/integration/DesignSurface/DesignSurfaceExt/DesignSurfaceExt.csproj

+4-18
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,18 @@
33
<PropertyGroup>
44
<AssemblyName>DesignSurfaceExt</AssemblyName>
55
<RootNamespace>DesignSurfaceExt</RootNamespace>
6-
<EnableXlfLocalization>false</EnableXlfLocalization>
7-
<UpdateXlfOnBuild>false</UpdateXlfOnBuild>
86
<ApplicationIcon>dll.ico</ApplicationIcon>
9-
<SignAssembly>false</SignAssembly>
107

11-
<NoWarn>$(NoWarn),SA1633</NoWarn>
128
<Copyright>Copyright © Paolo Foti 2008</Copyright>
139
<Company />
1410
<Authors>Paolo Foti</Authors>
1511
<PackageLicenseExpression>CPOL</PackageLicenseExpression>
1612
<PackageProjectUrl>https://www.codeproject.com/Articles/24385/Have-a-Great-DesignTime-Experience-with-a-Powerful</PackageProjectUrl>
17-
18-
<SuppressLicenseValidation>true</SuppressLicenseValidation>
19-
20-
<!-- Do not build this project when doing a .NET product build. -->
21-
<!-- The files for this project have been removed from the .NET product due to licensing issues. -->
22-
<ExcludeFromDotNetBuild>true</ExcludeFromDotNetBuild>
23-
<IsTestUtilityProject>true</IsTestUtilityProject>
24-
<ImplicitUsings>enable</ImplicitUsings>
2513
</PropertyGroup>
2614

27-
<ItemGroup>
28-
<ProjectReference Include="..\..\..\..\System.Design\src\System.Design.Facade.csproj" />
29-
<ProjectReference Include="..\..\..\..\System.Drawing.Design\src\System.Drawing.Design.Facade.csproj" />
30-
<ProjectReference Include="..\..\..\..\System.Windows.Forms.Design\src\System.Windows.Forms.Design.csproj" />
31-
<ProjectReference Include="..\..\..\..\System.Windows.Forms\System.Windows.Forms.csproj" />
32-
</ItemGroup>
15+
<PropertyGroup Condition="'$(TargetFramework)' == 'net481'">
16+
<SignAssembly>true</SignAssembly>
17+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
18+
</PropertyGroup>
3319

3420
</Project>

src/test/integration/DesignSurface/DesignSurfaceExt/NameCreationServiceImp.cs

+8-2
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,12 @@ public string CreateName(IContainer container, Type type)
3233
count++;
3334
try
3435
{
35-
int value = int.Parse(name[type.Name.Length..]);
36+
int value;
37+
#if NETFRAMEWORK
38+
value = int.Parse(name.Substring(type.Name.Length));
39+
#elif NETCOREAPP
40+
value = int.Parse(name[type.Name.Length..]);
41+
#endif
3642
if (value < min)
3743
min = value;
3844
if (value > max)
@@ -72,7 +78,7 @@ public bool IsValidName(string name)
7278
return false;
7379

7480
// - then don't allow a leading underscore
75-
if (name.StartsWith('_'))
81+
if (name[0] == '_')
7682
return false;
7783

7884
// - ok, it's a valid name
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<Project>
2+
3+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
4+
5+
<PropertyGroup>
6+
<EnableXlfLocalization>false</EnableXlfLocalization>
7+
<UpdateXlfOnBuild>false</UpdateXlfOnBuild>
8+
9+
<SuppressLicenseValidation>true</SuppressLicenseValidation>
10+
<NoWarn>$(NoWarn);SA1633</NoWarn>
11+
12+
<!-- Do not build this project when doing a .NET product build. -->
13+
<!-- The files for this project have been removed from the .NET product due to licensing issues. -->
14+
<ExcludeFromDotNetBuild>true</ExcludeFromDotNetBuild>
15+
<IsTestUtilityProject>true</IsTestUtilityProject>
16+
<TargetFrameworks>$(NetCurrent)-windows;net481</TargetFrameworks>
17+
<!-- Unset TargetFramework as this property gets set in Directory.Build.props. This is necessary to avoid over-building. -->
18+
<TargetFramework />
19+
20+
<LangVersion>latest</LangVersion>
21+
<ImplicitUsings>enable</ImplicitUsings>
22+
</PropertyGroup>
23+
24+
<ItemGroup Condition="'$(TargetFramework)' == '$(NetCurrent)-windows'">
25+
<PackageReference Include="System.Runtime.Serialization.Formatters" />
26+
</ItemGroup>
27+
28+
<ItemGroup Condition="'$(TargetFramework)' == '$(NetCurrent)-windows'">
29+
<ProjectReference Include="..\..\..\..\System.Design\src\System.Design.Facade.csproj" />
30+
<ProjectReference Include="..\..\..\..\System.Drawing.Design\src\System.Drawing.Design.Facade.csproj" />
31+
<ProjectReference Include="..\..\..\..\System.Windows.Forms.Design\src\System.Windows.Forms.Design.csproj" />
32+
<ProjectReference Include="..\..\..\..\System.Windows.Forms\System.Windows.Forms.csproj" />
33+
<ProjectReference Include="..\..\..\..\System.Drawing.Common\src\System.Drawing.Common.csproj" />
34+
</ItemGroup>
35+
36+
<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
37+
<Reference Include="System.Windows.Forms" />
38+
<Reference Include="System.Drawing" />
39+
<Reference Include="System.Design" />
40+
</ItemGroup>
41+
42+
<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
43+
<PackageReference Include="System.Resources.Extensions" VersionOverride="5.0.0"/>
44+
</ItemGroup>
45+
46+
</Project>

0 commit comments

Comments
 (0)