Skip to content

ASPNetCore shared framework pulls in System.Drawing.Common but doesn't use it. #42645

Closed

Description

@ericstj

I noticed today that ASPNetCore pulls in System.Drawing.Common. This struck me as odd because I wasn't sure why ASP.NET would need to deal with images. That seems like >1MB of unused code.

I did a bit of digging and found the following:

    Microsoft.AspNetCore.DataProtection & Microsoft.Extensions.Configuration.Xml > System.Security.Cryptography.Xml > System.Security.Permissions > System.Windows.Extensions > System.Drawing.Common

Crypto.Xml references System.Security.Permissions for only the Evidence type. It's exposed in it's public surface area. This type is useless in .NETCore and only used for source compat. This probably should have been omitted from the Crypto.Xml surface area, like we omitted all other uses of Evidence across the stack, however I bet Crypto.Xml was also thought to be legacy due to the spec/security issues with XML encryption. We could push this one type down (and EvidenceBase) to break the dependency between Crypto.Xml and System.Security.Permissions.

System.Security.Permissions references System.Windows.Extensions for only the XamlAccessLevel type. We could push this one type down to break this dependency. Then Permissions could reference only the assembly lower in the stack.

System.Windows.Extensions references System.Drawing.Common because we pushed types down. We can't break this dependency without making a binary breaking change (old code compiled against System.Windows.Extensions needs to resolve the types which have been moved down).

So we have two options to break dependencies here that involve pushing down tiny types. We should consider doing this in 6.0 to reduce the size of ASPNETCore and pull System.Drawing.Common out of it (as well as S.S.P). We just need to decide where to put these types 🤔

/cc @bartonjs @safern

Activity

  1. added
    untriaged
    on Sep 23, 2020
  2. ericstj commented on Sep 23, 2020

    @ericstj
    MemberAuthor

    So it looks like we initially didn't have the dependency from Crypto.Xml to Permissions. It was added here: dotnet/corefx#23417

  3. safern commented on Sep 23, 2020

    @safern
    Member

    We could move: System.Security.Policy.Evidence down to System.Security.AccessControl and we would break this dependency.

  4. removed
    untriaged
    on Sep 23, 2020
  5. added this to the 6.0.0 milestone on Sep 23, 2020
  6. bartonjs commented on Sep 24, 2020

    @bartonjs
    Member

    We could move: System.Security.Policy.Evidence down to System.Security.AccessControl and we would break this dependency.

    EvidenceBase needs to move along with it, but I had just independently come to the same conclusion. It's not a terribly inappropriate place for it.

  7. ericstj commented on Jan 7, 2021

    @ericstj
    MemberAuthor

    This just came up and is something we should do, preferably early, in 6.0. Moving types tends to require some babysitting as it flows through repos.

  8. added
    Bottom Up Work
    on Jan 7, 2021
  9. ericstj commented on Mar 17, 2021

    @ericstj
    MemberAuthor

    With dotnet/aspnetcore#30968 this is now fixed.

    The following assemblies were removed from ASPNETCore.

    • Microsoft.Win32.SystemEvents
    • System.Drawing.Common
    • System.Security.Permissions
    • System.Windows.Extensions

    @Anipik we should remove these from ASP.NET's transport package

  10. self-assigned this
    on Mar 17, 2021
  11. Anipik commented on Mar 19, 2021

    @Anipik
    Contributor

    sure, let me know if you are not working on this then i can go ahead make the changes

  12. ericstj commented on Mar 19, 2021

    @ericstj
    MemberAuthor

    @pranavkm @dougbu is it ok to remove these 4 assemblies from the transport package now?

  13. pranavkm commented on Mar 19, 2021

    @pranavkm
    Contributor

    Yup. They're gone - aspnet/Announcements#456

  14. ghost added
    in-pr
    on Mar 26, 2021
  15. ghost removed
    in-pr
    on Mar 26, 2021
  16. ghost locked as resolved and limited conversation to collaborators on Apr 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Bottom Up Workarea-System.Security

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions