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

WIP Initial Trimming Support #1508

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Commits on Apr 18, 2024

  1. Initial Trimming Support

    * Marked Spectre.Console and Spectre.Console.Cli as trimmable to enable warnings
    * Marked Demo.cspoj to be PublishedAOT and to include all trim warnings
    
    Spectre.Console
    * Marked Spectre.Console methods that used TypeConverter with suppressed messages
    * Marked ExceptionFormatter as requiring dynamic code, and added a fallback for AOT scenarios.
    
    Spectre.Console.Cli
    * Settings were discovered automatically with reflection. Added a new method for adding commands that allows explicit configuration of the settings to prevent them from being trimmed. Marked the old method as requiring dynamic code and pointed users to the new overload
    * Added attributes to the default TypeRegister to mark the types as being instantiated dynamically.
    * Suppressed a whole slew of warnings with command bulding and running the commands. With the commands and their settings being marked as having DynamicallyAccessedMembers this, theoretically, should work without error.
    
    Biggest worry is in CommandParameterComparer. The MetadataToken is stripped when published as AOT so it can't be used. A simple equals seems to work the same, but I'm not sure the historical reason MetadataToken is used here.
    phil-scott-78 committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    32226aa View commit details
    Browse the repository at this point in the history
  2. Add work around for NativeAOT bug with enums and DefaultValues

    Enums are converted to integers with NativeAOT on attribute constructors. This work around is needed until that bug is fixed. See dotnet/runtime#100688
    phil-scott-78 committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    714a09d View commit details
    Browse the repository at this point in the history
  3. Improves trim support for Commands with no settings

    Commands with no settings, such as those using the Data, have a better warning pushing users to use EmptyCommandSettings. EmptyCommandSettings is never
    instantiated directly, so it is marked as a DynamicDependency
    phil-scott-78 committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    5d79833 View commit details
    Browse the repository at this point in the history
  4. Uses Polysharp for AOT related attributes

    Adds polysharp for AOT attributes to reduce #IF statements. Also removes Nullable polyfill as polysharp provides that functionality too.
    phil-scott-78 committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    b4df56d View commit details
    Browse the repository at this point in the history
  5. Better use of DynamicallyAccessedMemberTypes and UnconditionalSuppres…

    …sMessage
    
    Tried to rip out UnconditionalSuppressMessage where types could be annotated properly. Also tried to get DynamicallyAccessedMemberTypes to better represent what
    members were being accessed - almost always it is a public constructor and public properties.
    
    Part of this exercise showed the need for a new CommandApp for DefaultCommands that accepts a parameter. Right now it lives side-by-side with the original CommandApp<T>
    phil-scott-78 committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    99412b9 View commit details
    Browse the repository at this point in the history
  6. Adding dedicated NativeAOT project

    Adding a nativeAot version of the demo application. While I was in here I fixed a few bugs in the original Demo though.
    phil-scott-78 committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    db3ce54 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    602f7de View commit details
    Browse the repository at this point in the history