dotnet / dotnet/macios

Reduce the number of static constructors

Open
#16,672 2 comments 2 reactions 0 assignees View on GitHub
app-size performance
Dominant language
C#
Stars
2.9k
Forks
576
Avg merge
2d 12h
Merged PRs (30d)
123

Description

Static constructors has a minor perf problem in that every time a class is used code has to be emitted to check if the static constructor has been called.

This means that if we can avoid a static constructor, it might be beneficial to try to do so (depending on what we need to do to make that happen).

The idea is to:

* [x] Fix #16671 first.
* [ ] Add a cecil test that lists all the types with static constructors, and verifies that we don't add new types with static constructors (basically add all existing types with static constructors as known failures / skipped types).
* A new cecil test can be found here: https://github.com/rolfbjarne/xamarin-macios/commit/7dcf539e8cbee300a9fac8a2c8a71734d285709f, but there's a snag: it will detect static constructors in pretty much every type, because the previous fix (#16671) only takes effect when an app is built.
* Possibly we'll have to test for static cctors in the "don't link" linker test instead.
* [ ] Go over each existing type with a static constructor and figure out if it's really necessary (sometimes it might very well be necessary).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.