Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Analyzer allows RUC/RAF in static constructor #2347

Closed

Description

@tlakollo

Trimmer generates warning IL2116 when RUC is placed in a static constructor but analyzer doesn't do anything in those cases, moreover, the behavior for RAF is undefined since it doesn't support RAF on type

Activity

  1. jtschuster commented on Dec 6, 2021

    @jtschuster
    Member

    Do you have an example of a piece of code where the trimmer raises the warning? I think this code should generate IL2116 but I'm not getting it when I publish self-contained.

    class Program {
        static int Main() {
            C c = new C();
            int v = C.m();
            Console.WriteLine($"{v}");
            return 0;
        }
    }
    
    class C {
        private static int x;
        public C() {  }
    
        [RequiresUnreferencedCode("asdf")]
        static C() { x = 1; }
    
        public static int m() { return x; }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions