diff --git a/src/OpenGL/Silk.NET.WGL/WGL.cs b/src/OpenGL/Silk.NET.WGL/WGL.cs index 888a08508e..7047093fec 100644 --- a/src/OpenGL/Silk.NET.WGL/WGL.cs +++ b/src/OpenGL/Silk.NET.WGL/WGL.cs @@ -41,20 +41,20 @@ public bool TryGetExtension(out T ext, nint hdc) public override bool IsExtensionPresent(string extension) => IsExtensionPresent(extension, GetCurrentDC()); - private ConcurrentDictionary> _extensions; + private readonly ConcurrentDictionary> _extensions = new(); [NativeApi(EntryPoint = "wglGetExtensionsStringARB")] private partial string GetExtensionsString(nint hdc); - private static HashSet? _empty; + private static readonly HashSet _empty = new(); private bool _hasGetExtensionsString; public bool IsExtensionPresent(string extension, nint hdc) => _extensions.GetOrAdd ( hdc, hdc => !(_hasGetExtensionsString = _hasGetExtensionsString || GetProcAddress("wglGetExtensionsStringARB") != 0) - ? _empty ??= new HashSet() - : new HashSet(GetExtensionsString(hdc).Split(' ')) + ? _empty + : new HashSet(GetExtensionsString(hdc).Split(' ')) ) .Contains(extension.StartsWith("WGL_") ? extension : $"WGL_{extension}"); }