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

NativeAOT Reflection-free mode: enum.IsDefined() shows different output #67477

Closed
smhmhmd opened this issue Apr 2, 2022 · 2 comments
Closed

Comments

@smhmhmd
Copy link
Contributor

smhmhmd commented Apr 2, 2022

Description

The same code shows different output is different when executed using dotnet runtime or run as a NativeAOT (compiled in reflection-free mode). This difference shows only in Reflection-free mode (IlcDisableReflection is set to true in csproj)

The sample code is from here

Reproduction Steps

Compile code from here
For NativeAOT add these to the csproj file

 <ItemGroup>
     <PackageReference Include="Microsoft.DotNet.ILCompiler" Version="7.0.0-*" />
  </ItemGroup>

<PropertyGroup>
    <InvariantGlobalization>true</InvariantGlobalization>
    <!-- Note: Program fails only when reflection is completely disabled as below -->
    <IlcDisableReflection>true</IlcDisableReflection>
 </PropertyGroup>

Expected behavior

    'dotnet run' shows expected output
        $ dotnet run
            1: True
            64: False
            Rodent: True
            Dog: True
            Dog, Cat: False
            None: True
            NONE: False
            9: False

Actual behavior

   NativeAOT shows:
        $ ./enum-isdefined
            1: False
            64: False
            Rodent: False
            1: False
            3: False
            None: False
            NONE: False
            9: False

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Apr 2, 2022
@jkotas
Copy link
Member

jkotas commented Apr 2, 2022

More usable reflection-free is tracked by #67193 . Enums behavior is one of the know issues of the current very experimental reflection-free mode.

Resolving as duplicate.

@jkotas jkotas closed this as completed Apr 2, 2022
@adamsitnik adamsitnik removed the untriaged New issue has not been triaged by the area owner label Apr 6, 2022
@ghost ghost locked as resolved and limited conversation to collaborators May 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants