Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Change System.Drawing.Common's target to netcoreapp2.0 #22833

Merged
merged 2 commits into from
Aug 2, 2017

Conversation

mellinoe
Copy link
Contributor

@mellinoe mellinoe commented Aug 1, 2017

There are two parts to this PR:

  1. Add a "netcoreapp" project to the "external" folder. This restores the .NET Core 2.0 targeting pack, so that assemblies can target and be built against it.
  2. Change the TargetGroup for System.Drawing.Common to netcoreapp2.0. Fix the minor incompatibilities mentioned in this issue: #22831.

@ericstj @weshaggard Could you take a look at the build configuration stuff that I have changed?

@mellinoe
Copy link
Contributor Author

mellinoe commented Aug 1, 2017

@dotnet-bot Test UWP CoreCLR x64 Debug Build

<RefPath>$(RefPath)</RefPath>
</BinPlaceConfiguration>
<BinPlaceConfiguration Include="$(Configuration)">
<!-- copy shims to the testhost as well in order to be able to run the netfx tests -->
Copy link
Member

Choose a reason for hiding this comment

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

Why? This seems broken. TestHostRootPath is set to a BuildConfiguration-specific path, not a configuration specific path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it seems wrong. It was copy-pasted from another project file (along with the $(RefPath) setting above). The shim part can probably be deleted.

<PropertyGroup>
<BinPlaceRef>true</BinPlaceRef>
<NuGetDeploySourceItem>Reference</NuGetDeploySourceItem>
<NETCoreAppPackageVersion>2.0.0-preview2-25407-01</NETCoreAppPackageVersion>
Copy link
Member

Choose a reason for hiding this comment

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

Don't we have a stable version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we do. I don't know why I only looked on nuget.org for this version.

Will fix.

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment to this project describing its purpose: to download a targeting pack only for a specific NETCoreApp version.

private const short StateNameValid = 0x0008;
private const long NotDefinedValue = 0;

private static readonly ConstructorInfo s_ctorKnownColor; // internal Color(KnownColor knownColor)
Copy link
Member

Choose a reason for hiding this comment

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

I can't recall the specific differences but I know in the past we avoid caching reflection objects and instead get a delegate (either bound or unbound) so that we can have minimal overhead for the lightup after initial setup. Have a look at CreateDelegate as a potential better optimization here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. I believe that also lets us avoid all of the temporary array allocations associated with invoking these reflection objects.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I'm not sure it works in this case. I am storing ConstructorInfo and FieldInfo objects, and you can't create Delegates out of those. Is that right?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, looking back at this code we never did it for fields. For constructors we created a func to Activator.CreateInstance. FWIW, this was the code I was remembering: https://github.com/Microsoft/referencesource/blob/master/Microsoft.Bcl/System.Threading.Tasks.v1.5/System/Lightup/Lightup.cs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I don't really see much value in that, TBH. Is there some large benefit to calling Activator.CreateInstance(Type, object[]) rather than just invoking a cached ConstructorInfo? We don't save out on the cost of the array allocation. My intuition says the ConstructorInfo would be faster, but I can't say that I've ever tested the difference between the two 😄 .

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I don't expect CreateInstance is any faster. Perhaps is has to do with what remains rooted when you keep these objects around? Honestly I can't remember and its been years since I touched that code. It could have been due to silverlight specifics as well since that was trying to work with SL. I think what you have is fine.

@mellinoe
Copy link
Contributor Author

mellinoe commented Aug 2, 2017

I'm going to merge this in now so I can go ahead with my packaging work.

@mellinoe mellinoe merged commit 87b5a4e into dotnet:master Aug 2, 2017
@ericstj
Copy link
Member

ericstj commented Aug 2, 2017

LGTM

private static readonly FieldInfo s_fieldKnownColor; // private readonly short knownColor
private static readonly FieldInfo s_fieldState; // private readonly short state

static ColorUtil()
Copy link
Member

Choose a reason for hiding this comment

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

Do we think reflection is the best option here? Why not just source sharing and changing the visibility?

@karelz karelz modified the milestone: 2.1.0 Aug 14, 2017
eerhardt added a commit to eerhardt/runtime that referenced this pull request Jun 17, 2021
With dotnet#22761 and dotnet/corefx#22833, BitmapSelector.Suffix will always be null. This means this feature is dead code, and users are unable to use it.

Removing this dead code because:

1. It doesn't do anything.
2. It is causing ILLink warnings, and it is easier to delete than to try to address the warnings.

I logged https://github.com/dotnet/runtime/issues/54363 to follow up and either re-implement this feature, or obsolete the attributes that no longer have any effect on the app.
eerhardt added a commit to dotnet/runtime that referenced this pull request Jun 21, 2021
With #22761 and dotnet/corefx#22833, BitmapSelector.Suffix will always be null. This means this feature is dead code, and users are unable to use it.

Removing this dead code because:

1. It doesn't do anything.
2. It is causing ILLink warnings, and it is easier to delete than to try to address the warnings.

I logged https://github.com/dotnet/runtime/issues/54363 to follow up and either re-implement this feature, or obsolete the attributes that no longer have any effect on the app.
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…etcoreapp20

Change System.Drawing.Common's target to netcoreapp2.0

Commit migrated from dotnet/corefx@87b5a4e
ViktorHofer pushed a commit to dotnet/winforms that referenced this pull request Dec 5, 2022
With dotnet/runtime#22761 and dotnet/corefx#22833, BitmapSelector.Suffix will always be null. This means this feature is dead code, and users are unable to use it.

Removing this dead code because:

1. It doesn't do anything.
2. It is causing ILLink warnings, and it is easier to delete than to try to address the warnings.

I logged https://github.com/dotnet/runtime/issues/54363 to follow up and either re-implement this feature, or obsolete the attributes that no longer have any effect on the app.

Commit migrated from dotnet/runtime@9199eb6
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants