Skip to content
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

Create shared CsWin32 with System.Drawing.Common #10525

Merged
merged 5 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Binary file added Build.complog
Binary file not shown.
6 changes: 6 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
<IsAnalyzerProject Condition="!$(IsTestProject) and
($(MSBuildProjectName.EndsWith('.Analyzers')) or $(MSBuildProjectName.EndsWith('.Analyzers.CSharp')))"
>true</IsAnalyzerProject>

<!--
XML cref tags don't resolve the same way code does. Until we can get this resolved we need to turn this off in
order to use CsWin32 in both System.Drawing and System.Windows.Forms.
-->
<NoWarn>$(NoWarn);CS1574;CS1580</NoWarn>
Copy link
Member

Choose a reason for hiding this comment

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

❓ Are you able to work around this issue using the approach described here?
#10320 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

Can't specify the root namespace for CsWin32 currently.

Copy link
Member

Choose a reason for hiding this comment

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

I believe you may have misunderstood my comment. My proposed solution is only relevant for cases where you cannot specify the root namespace.

Copy link
Member Author

Choose a reason for hiding this comment

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

My proposed solution is only relevant for cases where you cannot specify the root namespace.

@sharwell that is every case afaik

</PropertyGroup>

<!-- Making all tests run sequentially until we regroup tests. Tracked under issue https://github.com/dotnet/winforms/issues/8810. -->
Expand Down
49 changes: 35 additions & 14 deletions Winforms.sln
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Forms.Primit
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Forms.Primitives.Tests", "src\System.Windows.Forms.Primitives\tests\UnitTests\System.Windows.Forms.Primitives.Tests.csproj", "{9BFDE7F2-C8F3-40D6-9A16-8DCD1A37E900}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4AA2764C-B013-40B5-9E5B-9459EF976C8B}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
global.json = global.json
NuGet.Config = NuGet.Config
start-vs.cmd = start-vs.cmd
eng\Versions.props = eng\Versions.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Forms.Design.Editors.Facade3x", "src\System.Windows.Forms.Design.Editors\src\System.Windows.Forms.Design.Editors.Facade3x.csproj", "{E0681991-228A-420E-85D5-A9E796F0AAE0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Forms.Primitives.TestUtilities", "src\System.Windows.Forms.Primitives\tests\TestUtilities\System.Windows.Forms.Primitives.TestUtilities.csproj", "{73B0857A-966B-4E7D-8A83-FECFE0281AB9}"
Expand Down Expand Up @@ -165,6 +152,23 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScratchProject", "src\Syste
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrimTest", "src\System.Windows.Forms\tests\IntegrationTests\TrimTest\TrimTest.csproj", "{BA61D5A8-29E9-41AA-A3FA-B7F0A7F9A191}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Windows.Core", "src\System.Private.Windows.Core\src\System.Private.Windows.Core.csproj", "{61376D2A-4AD5-48F4-BF99-2BB630E21945}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "eng", "eng", "{8B4B1E09-B3C7-4044-B223-94EDEC1CAA20}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
global.json = global.json
NuGet.Config = NuGet.Config
eng\packageContent.targets = eng\packageContent.targets
eng\Publishing.props = eng\Publishing.props
start-vs.cmd = start-vs.cmd
eng\Versions.props = eng\Versions.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -905,6 +909,22 @@ Global
{BA61D5A8-29E9-41AA-A3FA-B7F0A7F9A191}.Release|x64.Build.0 = Release|Any CPU
{BA61D5A8-29E9-41AA-A3FA-B7F0A7F9A191}.Release|x86.ActiveCfg = Release|Any CPU
{BA61D5A8-29E9-41AA-A3FA-B7F0A7F9A191}.Release|x86.Build.0 = Release|Any CPU
{61376D2A-4AD5-48F4-BF99-2BB630E21945}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{61376D2A-4AD5-48F4-BF99-2BB630E21945}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61376D2A-4AD5-48F4-BF99-2BB630E21945}.Debug|arm64.ActiveCfg = Debug|Any CPU
{61376D2A-4AD5-48F4-BF99-2BB630E21945}.Debug|arm64.Build.0 = Debug|Any CPU
{61376D2A-4AD5-48F4-BF99-2BB630E21945}.Debug|x64.ActiveCfg = Debug|Any CPU
{61376D2A-4AD5-48F4-BF99-2BB630E21945}.Debug|x64.Build.0 = Debug|Any CPU
{61376D2A-4AD5-48F4-BF99-2BB630E21945}.Debug|x86.ActiveCfg = Debug|Any CPU
{61376D2A-4AD5-48F4-BF99-2BB630E21945}.Debug|x86.Build.0 = Debug|Any CPU
{61376D2A-4AD5-48F4-BF99-2BB630E21945}.Release|Any CPU.ActiveCfg = Release|Any CPU
{61376D2A-4AD5-48F4-BF99-2BB630E21945}.Release|Any CPU.Build.0 = Release|Any CPU
{61376D2A-4AD5-48F4-BF99-2BB630E21945}.Release|arm64.ActiveCfg = Release|Any CPU
{61376D2A-4AD5-48F4-BF99-2BB630E21945}.Release|arm64.Build.0 = Release|Any CPU
{61376D2A-4AD5-48F4-BF99-2BB630E21945}.Release|x64.ActiveCfg = Release|Any CPU
{61376D2A-4AD5-48F4-BF99-2BB630E21945}.Release|x64.Build.0 = Release|Any CPU
{61376D2A-4AD5-48F4-BF99-2BB630E21945}.Release|x86.ActiveCfg = Release|Any CPU
{61376D2A-4AD5-48F4-BF99-2BB630E21945}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -927,7 +947,7 @@ Global
{6103E743-057D-41C6-946C-23A751A08748} = {088DD24C-DF6B-45F3-A8BC-592580A4B2A9}
{088DD24C-DF6B-45F3-A8BC-592580A4B2A9} = {77FEDB47-F7F6-490D-AF7C-ABB4A9E0B9D7}
{48979B4E-EAEC-4B41-BB49-44CA230BECAB} = {680FB14C-7B0C-4D63-9F1A-18ACCDB0F52A}
{462AD69A-9395-4E98-882D-569CDE562559} = {4AA2764C-B013-40B5-9E5B-9459EF976C8B}
{462AD69A-9395-4E98-882D-569CDE562559} = {8B4B1E09-B3C7-4044-B223-94EDEC1CAA20}
{D390F7D2-1E11-4DEE-B7F1-4FD0681A81F0} = {DF68A171-D27B-4E6A-8A7E-63A651622355}
{55E34830-B375-41FF-AFCA-F53B80A4D152} = {77FEDB47-F7F6-490D-AF7C-ABB4A9E0B9D7}
{D8598EC8-D64B-4BE7-A4DC-5D5CED6A3938} = {583F1292-AE8D-4511-B8D8-A81FE4642DDC}
Expand Down Expand Up @@ -965,6 +985,7 @@ Global
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D} = {77FEDB47-F7F6-490D-AF7C-ABB4A9E0B9D7}
{7650F24E-7132-42CF-ADCE-830C8DB26EE5} = {583F1292-AE8D-4511-B8D8-A81FE4642DDC}
{BA61D5A8-29E9-41AA-A3FA-B7F0A7F9A191} = {680FB14C-7B0C-4D63-9F1A-18ACCDB0F52A}
{61376D2A-4AD5-48F4-BF99-2BB630E21945} = {77FEDB47-F7F6-490D-AF7C-ABB4A9E0B9D7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7B1B0433-F612-4E5A-BE7E-FCF5B9F6E136}
Expand Down
43 changes: 40 additions & 3 deletions eng/packageContent.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<_DotnetApiDocsPackageName>Microsoft.Private.Intellisense</_DotnetApiDocsPackageName>
<!-- Using ToLower below to unlock Linux build, even if it's unsupported. -->
<_DotnetApiDocsFilesRoot>$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', '$(_DotnetApiDocsPackageName.ToLower())', '$(MicrosoftPrivateIntellisenseVersion)', 'IntellisenseFiles', 'windowsdesktop', '1033'))</_DotnetApiDocsFilesRoot>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);IncludeProjectReferencesWithPackAttributeInPackage</TargetsForTfmSpecificContentInPackage>

<!-- During NoBuild pack invocations, skip project reference build. Necessary for the IncludeProjectReferencesWithPackAttributeInPackage target. -->
<BuildProjectReferences Condition="'$(NoBuild)' == 'true'">false</BuildProjectReferences>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -52,12 +56,12 @@
</PropertyGroup>

<!--
If this file does NOT exist, and the assembly is NOT a facade assembly, this is an error.
If this file does NOT exist, and the assembly is NOT a facade assembly, this is an error.
This means we build a real assembly that has no associated official intellisense docs.
Contact the intellisense team for guidance.
-->
<Error Condition="!Exists('$(IntellisenseXmlFileSource)') and '$(IsFacadeAssembly)' != 'true' and '$(IsAnalyzerProject)' != 'true'"
Text="$(AssemblyName).xml was not found in $(_DotnetApiDocsPackageName) package. Contact the intellisense team about adding the docs for this assembly."
<Error Condition="!Exists('$(IntellisenseXmlFileSource)') and '$(IsFacadeAssembly)' != 'true' and '$(IsAnalyzerProject)' != 'true' and '$(HasNoPublicIntellisense)' != 'true'"
JeremyKuhne marked this conversation as resolved.
Show resolved Hide resolved
Text="$(AssemblyName).xml was not found in $(_DotnetApiDocsPackageName) package. Contact the intellisense team about adding the docs for this assembly."
/>

<ItemGroup>
Expand Down Expand Up @@ -92,4 +96,37 @@
DestinationFiles="$(IntellisenseXmlDest)"
SkipUnchangedFiles="true" />
</Target>

<!-- This is copied from runtime/eng/packaging.targets to allow adding additional project references to packages. -->
<Target Name="IncludeProjectReferencesWithPackAttributeInPackage"
Condition="'@(ProjectReference)' != '' and @(ProjectReference->AnyHaveMetadataValue('Pack', 'true'))"
DependsOnTargets="BuildOnlySettings;ResolveReferences">
<PropertyGroup>
<_referringTargetFramework>$(TargetFramework)</_referringTargetFramework>
<_referringTargetFramework Condition="'$(PackageUsePlatformTargeting)' != 'true' and $(TargetFramework.Contains('-'))">$(TargetFramework.SubString(0, $(TargetFramework.IndexOf('-'))))</_referringTargetFramework>
</PropertyGroup>

<ItemGroup>
<!-- Add ReferenceCopyLocalPaths for ProjectReferences which are flagged as Pack="true" into the package. -->
<_projectReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference')->WithMetadataValue('Pack', 'true'))" />
<TfmSpecificPackageFile Include="@(_projectReferenceCopyLocalPaths)"
PackagePath="$([MSBuild]::ValueOrDefault('%(ReferenceCopyLocalPaths.PackagePath)', '$(BuildOutputTargetFolder)\$(_referringTargetFramework)\'))" />
<TfmSpecificDebugSymbolsFile Include="@(TfmSpecificPackageFile->WithMetadataValue('Extension', '.pdb'))"
TargetPath="/%(TfmSpecificPackageFile.PackagePath)/%(Filename)%(Extension)"
TargetFramework="$(_referringTargetFramework)"
Condition="'$(IncludeSymbols)' == 'true'" />
<!-- Remove symbol from the non symbol package. -->
<TfmSpecificPackageFile Remove="@(TfmSpecificPackageFile->WithMetadataValue('Extension', '.pdb'))" />
<!-- If the reference assembly is included, don't put the documentation file next to the lib assembly. -->
<TfmSpecificPackageFile Remove="@(_projectReferenceCopyLocalPaths->WithMetadataValue('Extension', '.xml')->WithMetadataValue('IncludeReferenceAssemblyInPackage', 'true'))" />
</ItemGroup>

<ItemGroup>
<!-- Include the reference assembly and put the documentation file next to it. -->
<_referenceAssemblyPaths Include="@(_projectReferenceCopyLocalPaths->WithMetadataValue('Extension', '.dll')->WithMetadataValue('IncludeReferenceAssemblyInPackage', 'true')->Metadata('ReferenceAssembly'))" />
<_referenceAssemblyPaths Include="@(_projectReferenceCopyLocalPaths->WithMetadataValue('Extension', '.xml')->WithMetadataValue('IncludeReferenceAssemblyInPackage', 'true'))" />
<TfmSpecificPackageFile Include="@(_referenceAssemblyPaths)"
PackagePath="ref\$(_referringTargetFramework)\" />
</ItemGroup>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<!--
This project packages the output of the referenced projects into a single nupkg.

There are two main ways to work around this:
There are two main ways to work around this:

1. A pull model where a single project pulls in everything that the package needs.
a. This is the model we're using because it's less work and we only have a few more binaries coming in the future.
b. An example of the pull model is at https://github.com/nuget/home/issues/3891#issuecomment-377319939, with official docs
at https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#targetsfortfmspecificbuildoutput
at https://docs.microsoft.com/nuget/reference/msbuild-targets#targetsfortfmspecificbuildoutput

2. A push model where projects control what they contribute to the package.
a. An example of the push model is at https://github.com/dotnet/machinelearning/blob/master/pkg/Directory.Build.props.
a. An example of the push model is at https://github.com/dotnet/machinelearning/blob/master/pkg/Directory.Build.props.
-->

<PropertyGroup>
Expand Down Expand Up @@ -82,6 +82,9 @@
<!-- Reference and Source System.Windows.Forms -->
<ProjectReference Include="..\..\src\System.Windows.Forms\src\System.Windows.Forms.csproj" />

<!-- Reference and Source System.Windows.Forms.Primitives -->
<ProjectReference Include="..\..\src\System.Private.Windows.Core\src\System.Private.Windows.Core.csproj" />

<!-- Reference and Source System.Windows.Forms.Primitives -->
<ProjectReference Include="..\..\src\System.Windows.Forms.Primitives\src\System.Windows.Forms.Primitives.csproj" />

Expand All @@ -99,7 +102,7 @@

<ProjectReference Include="..\..\src\Accessibility\src\Accessibility.ilproj" />

<!--
<!--
Analyzers
-->
<ProjectReference Include="..\..\src\System.Windows.Forms.Analyzers\src\System.Windows.Forms.Analyzers.csproj" />
Expand Down
4 changes: 2 additions & 2 deletions pkg/Microsoft.Private.Winforms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ If the content of these files differ - the build will fail.
To update the manifest run the following command and check in the updated files manifest:

```
.\build.cmd -pack /p:GenerateManifest=true
.\build.cmd -pack /p:_GenerateManifest=true
```

To debug the script run the following command:

```
dotnet build .\pkg\Microsoft.Private.Winforms\Microsoft.Private.Winforms.csproj /t:UpdateTransportPackage /p:GenerateManifest=true /v:m /bl /p:CommonLibrary_NativeInstallDir=$env:UserProfile\.netcoreeng\native\
dotnet build .\pkg\Microsoft.Private.Winforms\Microsoft.Private.Winforms.csproj /t:UpdateTransportPackage /p:_GenerateManifest=true /v:m /bl /p:CommonLibrary_NativeInstallDir=$env:UserProfile\.netcoreeng\native\
```


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
<FrameworkListFileClass Include="System.Windows.Forms.Design.Editors.dll" Profile="WindowsForms" />
<FrameworkListFileClass Include="System.Windows.Forms.dll" Profile="WindowsForms" />
<FrameworkListFileClass Include="System.Windows.Forms.Primitives.dll" Profile="WindowsForms" />
<FrameworkListFileClass Include="System.Private.Windows.Core.dll" Profile="WindowsForms" />
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions src/System.Drawing.Common/src/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@

global using System.Diagnostics;
global using System.Diagnostics.CodeAnalysis;
global using Windows.Win32;
global using Windows.Win32.Foundation;
global using Windows.Win32.Graphics.Gdi;
global using Windows.Win32.Graphics.GdiPlus;
global using Windows.Win32.System.Memory;

This file was deleted.

20 changes: 0 additions & 20 deletions src/System.Drawing.Common/src/Interop/Windows/Interop.BOOL.cs

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading