Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ paket-files/
.idea/
*.sln.iml

# ClaudiaIDE extension
.claudiaideconfig

# CodeRush
.cr/

Expand Down
9 changes: 8 additions & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
<MicrosoftDotNetXUnitExtensionsPackageVersion>10.0.0-beta.25209.3</MicrosoftDotNetXUnitExtensionsPackageVersion>
<MicrosoftNETTestSdkVersion>17.4.0-preview-20220707-01</MicrosoftNETTestSdkVersion>
</PropertyGroup>
<!-- Below have no corresponding entries in Versions.Details.XML because they are not updated via Maestro -->
<!-- Below have no corresponding entries in Versions.Details.XML because they are not updated via
Maestro -->
<!-- XUnit-related (not extensions) -->
<PropertyGroup>
<XUnitVersion>2.9.2</XUnitVersion>
Expand Down Expand Up @@ -114,4 +115,10 @@
<!-- Pin transitive dependency to avoid vulnerable 8.0.0 version. -->
<SystemFormatsAsn1PackageVersion>8.0.1</SystemFormatsAsn1PackageVersion>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
<PackageReference Include="System.Collections.Immutable" VersionOverride="9.0.2" />
<PackageReference Include="System.Resources.Extensions" VersionOverride="5.0.0" />
</ItemGroup>

</Project>
37 changes: 18 additions & 19 deletions src/test/integration/DesignSurface/DemoConsole/DemoConsole.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,43 @@
<ApplicationIcon>painter.ico</ApplicationIcon>
<OutputType>WinExe</OutputType>
<StartupObject />
<EnableXlfLocalization>false</EnableXlfLocalization>
<UpdateXlfOnBuild>false</UpdateXlfOnBuild>
<NoWarn>$(NoWarn);SA1633;CS8002</NoWarn>
<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>
<PackageProjectUrl>
https://www.codeproject.com/Articles/24385/Have-a-Great-DesignTime-Experience-with-a-Powerful</PackageProjectUrl>
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
</PropertyGroup>

<!-- 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>
<ImplicitUsings>enable</ImplicitUsings>
<PropertyGroup Condition="'$(TargetFramework)' == 'net481'">
<NoWarn>$(NoWarn)CS8002;CA1824</NoWarn>
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Runtime.Serialization.Formatters" />
<EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator"
LastGenOutput="Resources.Designer.cs" />
<Compile Update="Properties\Resources.Designer.cs" AutoGen="True" DependentUpon="Resources.resx"
DesignTime="True" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\System.Drawing.Common\src\System.Drawing.Common.csproj" />
<ProjectReference Include="..\..\..\..\System.Windows.Forms.Design\src\System.Windows.Forms.Design.csproj" />
<ProjectReference Include="..\..\..\..\System.Windows.Forms\System.Windows.Forms.csproj" />
<ProjectReference Include="..\DesignSurfaceExt\DesignSurfaceExt.csproj" />
</ItemGroup>

<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" />
</ItemGroup>

<ItemGroup>
<None Update="painter.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<Content Include="..\README.md">
<Link>..\README.md</Link>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace TestConsole;

public partial class MainForm
{
[DesignerCategory("Default")]
internal class MyUserControl : UserControl
{
public MyUserControl()
Expand Down Expand Up @@ -40,7 +41,7 @@ public void InitializeComponent()
Size = new(30, 30)
};

Controls.AddRange(textBox2, textBox1, textBox);
Controls.AddRange([textBox2, textBox1, textBox]);
}
}
}
29 changes: 28 additions & 1 deletion src/test/integration/DesignSurface/DemoConsole/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace TestConsole;

[DesignerCategory("Default")]
public partial class MainForm : Form
{
private ISelectionService _selectionService;
Expand Down Expand Up @@ -264,6 +265,7 @@ private void CreateDesignSurface(int n)
rootComponent.Text = "Root Component hosted by the DesignSurface N.5";

surface.CreateControl<TabControl>(new Size(400, 100), new Point(12, 21));
// See https://github.com/microsoft/winforms-designer/issues/2508
surface.CreateControl<TableLayoutPanel>(new Size(290, 160), new Point(20, 150));
surface.CreateControl<PropertyGrid>(new Size(200, 150), new Point(430, 23));
surface.CreateComponent<NotifyIcon>();
Expand All @@ -290,6 +292,7 @@ private void CreateDesignSurface(int n)

ToolStrip toolStrip1 = surface.CreateControl<ToolStrip>(new Size(400, 50), new Point(0, 0));
ToolStripButton toolStripButton1 = surface.CreateComponent<ToolStripButton>();
// See https://github.com/dotnet/winforms/issues/13040
ToolStripDropDownButton toolStripDropDownButton1 = surface.CreateComponent<ToolStripDropDownButton>();
ToolStripTextBox toolStripTextBox = surface.CreateComponent<ToolStripTextBox>();
toolStrip1.Items.Add(toolStripButton1);
Expand Down Expand Up @@ -349,7 +352,7 @@ private void CreateDesignSurface(int n)
splitterPanel1.Controls.Add(richTextBox);
splitterPanel2.Controls.Add(scrollableControl);

toolStripContainer.ContentPanel.Controls.AddRange(splitContainer);
toolStripContainer.ContentPanel.Controls.Add(splitContainer);

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

Expand All @@ -362,6 +365,10 @@ private void CreateDesignSurface(int n)
NumericUpDown numericUpDown = surface.CreateControl<NumericUpDown>(new(50, 10), new(10, 10));
panel.Controls.Add(numericUpDown);

// A nested host is required for .NET Framework.
// See https://github.com/dotnet/winforms/issues/11866#issuecomment-2673266564
// and https://github.com/dotnet/winforms/issues/13248#issuecomment-2803589449
#if NETCOREAPP
BindingNavigator bindingNavigator = surface.CreateControl<BindingNavigator>(new(0, 0), new(0, 0));

BindingSource bindingSource = new()
Expand All @@ -375,6 +382,26 @@ private void CreateDesignSurface(int n)
richTextBox.DataBindings.Add(new Binding("Text", bindingSource, "Text", true, DataSourceUpdateMode.OnPropertyChanged));

panel.Controls.Add(bindingNavigator);
#endif

#if NETFRAMEWORK
IDesignerHost designerHost = surface.GetIDesignerHost();
DesignerActionService designerActionService = (DesignerActionService)designerHost.GetService(typeof(DesignerActionService));

DesignerActionListCollection dataGridViewActionLists = designerActionService.GetComponentActions(toolStripContainer);

foreach (DesignerActionList actionList in dataGridViewActionLists)
{
actionList.AutoShow = false;
}

DesignerActionListCollection toolStripContainerActionLists = designerActionService.GetComponentActions(toolStripContainer);

foreach (DesignerActionList actionList in toolStripContainerActionLists)
{
actionList.AutoShow = false;
}
#endif
}

break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"profiles": {
"DemoConsole": {
"commandName": "Project",
"nativeDebugging": false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ private TComponent CreateComponent<TComponent>(out IDesignerHost host)

if (designer is IComponentInitializer initializer)
{
initializer.InitializeNewComponent(null);
// This is to address a difference in nullability annotations between the .NET and NETFX
// See https://github.com/dotnet/winforms/pull/12996/#issuecomment-2765302289
initializer.InitializeNewComponent(new Dictionary<object, object>());
}

return (TComponent)newComp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,19 @@
<PropertyGroup>
<AssemblyName>DesignSurfaceExt</AssemblyName>
<RootNamespace>DesignSurfaceExt</RootNamespace>
<EnableXlfLocalization>false</EnableXlfLocalization>
<UpdateXlfOnBuild>false</UpdateXlfOnBuild>
<ApplicationIcon>dll.ico</ApplicationIcon>
<SignAssembly>false</SignAssembly>

<NoWarn>$(NoWarn),SA1633</NoWarn>
<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>

<!-- 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>
<ImplicitUsings>enable</ImplicitUsings>
<PackageProjectUrl>
https://www.codeproject.com/Articles/24385/Have-a-Great-DesignTime-Experience-with-a-Powerful</PackageProjectUrl>
</PropertyGroup>

<ItemGroup>
<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="..\..\..\..\System.Windows.Forms\System.Windows.Forms.csproj" />
</ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net481'">
<SignAssembly>true</SignAssembly>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// - NameCreationServiceImp - Implementing INameCreationService
// - The INameCreationService interface is used to supply a name to the control just created
// - In the CreateName() we use the same naming algorithm used by Visual Studio: just
// - increment an integer counter until we find a name that isn't already in use.
namespace DesignSurfaceExt;

/// <summary>
/// Implements <see cref="INameCreationService"/> to provide names for newly created controls.
/// </summary>
/// <remarks>
/// <para>The <see cref="INameCreationService"/> interface is used to generate names for newly created controls.
/// The <c>CreateName</c> method follows the same naming algorithm used by Visual Studio:
/// it increments an integer counter until it finds a unique name that is not already in use.</para>
/// </remarks>
internal sealed class NameCreationServiceImp : INameCreationService
{
public NameCreationServiceImp() { }
Expand All @@ -32,7 +36,12 @@ public string CreateName(IContainer container, Type type)
count++;
try
{
int value = int.Parse(name[type.Name.Length..]);
int value;
#if NETFRAMEWORK
value = int.Parse(name.Substring(type.Name.Length));
#elif NETCOREAPP
value = int.Parse(name[type.Name.Length..]);
#endif
if (value < min)
min = value;
if (value > max)
Expand Down Expand Up @@ -72,7 +81,7 @@ public bool IsValidName(string name)
return false;

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

// - ok, it's a valid name
Expand Down
57 changes: 57 additions & 0 deletions src/test/integration/DesignSurface/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<Project>

<Import
Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup>
<EnableXlfLocalization>false</EnableXlfLocalization>
<UpdateXlfOnBuild>false</UpdateXlfOnBuild>

<SuppressLicenseValidation>true</SuppressLicenseValidation>
<NoWarn>$(NoWarn);SA1633</NoWarn>

<!-- 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>
<!-- Unset TargetFramework as this property gets set in the repo's root. This is necessary to
avoid over-building. -->
<TargetFramework />

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

<PropertyGroup Condition="'$(TargetFramework)' == 'net481'">
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net481'">
<!-- Include the Framework specific items as none so we can see them easily in the Solution
Explorer. -->
<None Include="**/Framework/*" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == '$(NetCurrent)-windows'">
<PackageReference Include="System.Runtime.Serialization.Formatters" />
</ItemGroup>

<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" />
<ProjectReference
Include="..\..\..\..\System.Windows.Forms.Design\src\System.Windows.Forms.Design.csproj" />
<ProjectReference Include="..\..\..\..\System.Windows.Forms\System.Windows.Forms.csproj" />
<ProjectReference Include="..\..\..\..\System.Drawing.Common\src\System.Drawing.Common.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Drawing" />
<Reference Include="System.Design" />
</ItemGroup>

</Project>
Loading
Loading