Skip to content

Test plan for "module initializers" feature #40500

@jcouv

Description

@jcouv

Championed issue: dotnet/csharplang#2608
Specification: https://github.com/dotnet/csharplang/blob/master/proposals/module-initializers.md

  • LangVer
  • missing module init type: [ModuleInit(typeof(Missing))]
  • module init type has a use-site error [ModuleInit(typeof(A))] where A can't be fully loaded (A defined in a library, but it's base type is referenced in another library which is not referenced in current/client library)
  • test some netmodule scenarios (adding multiple modules within an assembly)
  • attribute on local functions
  • attribute on static and non-static methods
  • attribute on methods with parameters
  • attribute on non-void methods
  • attribute on generic methods
  • attribute on methods directly or indirectly in a generic type, method is generic and not generic
  • attribute on methods inaccessible on the module level
  • attribute on method inside an added .NET module compiled from IL. Expect the method to be not executed.
  • attribute on multiple methods in source. Expect methods are executed in lexical order. The spec should clarify the order.
  • different methods decorated with different attributes (extern aliases). Should make no difference, all methods should be executed.
  • methods decorated with the attribute using constructor other than default are ignored.
  • multiple attributes on the same method (change attribute definition to allow multiple applications)
  • attributes on legacy partial methods: on definition, on implementation, on both (change attribute definition to allow multiple applications)
  • attributes on new-style partial methods: on definition, on implementation, on both (change attribute definition to allow multiple applications)
  • attributes on a static constructor
  • attributes on methods in an interface
  • attributes on non-method declarations (change attribute definition to allow), should be ignored.
  • attribute on conditional method
  • attribute is conditional
  • attribute on an obsolete method
  • Error when attribute is used in VB
  • No warning when module initializer method initializes a static field with a non-nullable reference type seems to be a difficult analysis to reason about correctly. Test plan for "module initializers" feature #40500 (comment)
  • Expected semantics for static int field = default; when module initializer also writes to field
    • the optimization should not be a problem because the static constructor will run before the module initializer can write anything.

BCL

LDM

FYI @jnm2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-CompilersDocumentationTestTest failures in roslyn-CITest-GapDescribes a specific feature or scenario that does not have test coverage

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions