-
Notifications
You must be signed in to change notification settings - Fork 4.9k
TypeConverters for System.Drawing #33092
TypeConverters for System.Drawing #33092
Conversation
src/System.Windows.Extensions/ref/System.ComponentModel.TypeConverter.cs
Outdated
Show resolved
Hide resolved
@safern I looked at the logs of those two failing checks, but I do not understand what to do. |
test Linux x64 Release Build please |
src/System.Windows.Extensions/src/System/Drawing/IconConverter.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Extensions/tests/System/Drawing/ImageFormatConverterTests.cs
Show resolved
Hide resolved
src/System.Windows.Extensions/tests/System/Drawing/ImageFormatConverterTests.cs
Show resolved
Hide resolved
FYI: @ericstj |
src/System.Windows.Extensions/tests/System/Drawing/ImageFormatConverterTests.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Extensions/tests/System/Drawing/ImageFormatConverterTests.cs
Outdated
Show resolved
Hide resolved
test Linux arm64 Release Build |
@satano ApiCompat was not running and was just fixed in: #33152 Would you mind rebasing on top of master and building the project, it should fail, then fixing the errors by adding these attributes to the ref? @ericstj I expect this to fail for netcoreapp2.0 as well since the ref is built against netstandard and we're not including these attributes to netcoreapp2.0 implementation since System.Windows.Extensions is not supported in netcoreapp2.0. So should we add a netcoreapp3.0 ref and if def those attributes in the ref as well? |
I suspect this is the error you're seeing: 15:13:28 D:\j\workspace\windows-TGrou---0d2c9ac4.packages\microsoft.dotnet.apicompat\1.0.0-beta.18530.4\build\Microsoft.DotNet.ApiCompat.targets(68,5): error : CannotRemoveAttribute : Attribute 'System.ComponentModel.TypeConverterAttribute' exists on 'System.Drawing.Imaging.ImageFormat' in the contract but not the implementation. [D:\j\workspace\windows-TGrou---0d2c9ac4\src\System.Drawing.Common\src\System.Drawing.Common.csproj] That error is for netcoreapp2.0 -- this is what I was talking about in:
So in order to fix it, add a netcoreapp configuration to the ref configurations.props and then the attributes that you added to the ref file, wrap them up inside an #if netcoreapp as well. |
@satano since we're going to soon be forking our release branch for 3.0 and this is a priority for that I pushed the remaining changes. Thanks for pushing so hard towards getting this into netcoreapp3.0 😄 |
@@ -279,6 +279,9 @@ public enum CopyPixelOperation | |||
SourcePaint = 15597702, | |||
Whiteness = 16711778, | |||
} | |||
#if netcoreapp |
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.
NIT: if you wanted to avoid the define you could put these in a separate file. EG: System.Drawing.Common.netcoreapp.cs
[System.ComponentModel.TypeConverter("System.Drawing.FontConverter, System.Windows.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")]
public sealed partial class Font { }
...
I've done that in some other places.
</ItemGroup> | ||
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'"> | ||
<Reference Include="System.Buffers" /> | ||
<Reference Include="System.Memory" /> |
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.
Nit: ordering
<Compile Include="$(CommonPath)\CoreLib\System\Text\ValueStringBuilder.cs"> | ||
<Link>CoreLib\System\Text\ValueStringBuilder.cs</Link> | ||
</Compile> | ||
<Compile Include="System\Drawing\FontConverter.cs" /> |
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 noticed that a lot of these look different from desktop. Looking through the PR history I see that these were ported from mono rather than desktop. That's a good start but some callers may care about the desktop behavior on Windows /cc @dreddy-work @safern
@@ -2,7 +2,7 @@ | |||
<PropertyGroup> | |||
<ProjectGuid>{D7AEA698-275D-441F-B7A7-8491D1F0EFF0}</ProjectGuid> | |||
<IsPartialFacadeAssembly Condition="'$(TargetsNetFx)' == 'true'">true</IsPartialFacadeAssembly> | |||
<Configurations>net461-Debug;net461-Release;netfx-Debug;netfx-Release;netstandard-Debug;netstandard-Release</Configurations> | |||
<Configurations>net461-Debug;net461-Release;netcoreapp-Debug;netcoreapp-Release;netfx-Debug;netfx-Release;netstandard-Debug;netstandard-Release</Configurations> |
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 is what broke the build. NETCoreApp builds from source, so you need to use project references for this.
@safern Im sorry I was quiet for some time. I did not have time for last week or so to look at this. Is there anything more to do? The build are still failing. |
Sorry. I accidently clicked "Close and comment". |
src/System.Windows.Extensions/src/System/Drawing/IconConverter.cs
Outdated
Show resolved
Hide resolved
…usStateException project.
…ces for netstandard
The builds were still failing because we needed to change all the references to be project reference and only for netcoreapp. For netstandard we don't need references. I also rebased on top of master. |
@dotnet-bot test this please (rudely terminated) |
test NETFX x86 Release Build please |
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.
LGTM! Thanks for all the hard effort @satano!!
@safern You (all) are welcome. :) |
Yes, your work and patience much appreciated @satano . If you choose to consider another up-for-grabs issue, I am confident it will not take 5 months to merge this time 😊 |
What would be required to use this in a .net standard 2.0 project? Is this possible? |
Unfortunately no. These converters are only available when you target |
* Moved InvalidAsynchronousStateExceptionTests to the InvalidAsynchronousStateException project. * Added Font, Icon, Image and ImageFormat converters. * Source code in "ref" is in one file * Converters are only for Windows. * TypeConverter attribute is only for netcoreapp. * Icon can be converted to Bitmap, some tests skipped on NETFX. * Bitmap as not supported conversion removed from tests. * Typo * TypeConverterAttribute in ref project * TypeConverterAttribute is with full name in ref project * IconConverter added to unix Icon * Add netcoreapp3.0 ref assembly containing TypeConverters in windows.extensions * Addressed comments: project reference, invalid cast. * Make all references for netcoreapp project references, delete references for netstandard Commit migrated from dotnet/corefx@78cf4e4
Closes #21129
Added type converters according to this comment. All the classes and their tests were just taken from previous PR.