Runtime: Make Microsoft.Win32.SystemEvents static

Created on 9 Jul 2019  路  6Comments  路  Source: dotnet/runtime

This is a holdover "static like class" from pre .NET 2.0 that wasn't made static.

Current:

``` C#
namespace Microsoft.Win32
{
public sealed class SystemEvents
{
private SystemEvents()
{
}
}
}

Proposed:

``` C#
namespace Microsoft.Win32
{
    public static class SystemEvents
    {
    }
}
api-approved area-Microsoft.Win32 up-for-grabs

Most helpful comment

@Marusyk, feel free to give it a shot. This particular one is a little tricky to accomplish. :)

All 6 comments

Video

(You can use this issue for any class where all public APIs are static, all constructors are private, and the type is sealed)

Just curious is there any benefit to doing this other than tidiness? (which is fine). Such as perf.

I can prepare PR for this. If it is really needed then please assign the issue to me

@Marusyk, feel free to give it a shot. This particular one is a little tricky to accomplish. :)

This is a holdover "static like class" from pre .NET 2.0 that wasn't made static.

It's instantiated in the implementation:
https://github.com/dotnet/corefx/blob/b75421a0035bf3a44e1f68447255470d57074dbb/src/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs#L481
and
https://github.com/dotnet/corefx/blob/b75421a0035bf3a44e1f68447255470d57074dbb/src/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs#L491
as part of lazily-initializing the instance, and the lazy initialization factors in information about the thread that's doing the initialization.

This doesn't seem worth changing to me. @JeremyKuhne, can this be closed, or are you hoping the implementation will be overhauled?

Was this page helpful?
0 / 5 - 0 ratings