-
-
Notifications
You must be signed in to change notification settings - Fork 248
/
RoslynUtility.cs
35 lines (30 loc) · 1.12 KB
/
RoslynUtility.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) Josef Pihrt and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable;
using System.Linq;
using System.Reflection;
using System.Threading;
using Microsoft.CodeAnalysis;
namespace Roslynator
{
internal static class RoslynUtility
{
private static ImmutableHashSet<string> _wellKnownLanguageNames;
public static ImmutableHashSet<string> WellKnownLanguageNames
{
get
{
if (_wellKnownLanguageNames == null)
Interlocked.CompareExchange(ref _wellKnownLanguageNames, LoadLanguageNames(), null);
return _wellKnownLanguageNames;
static ImmutableHashSet<string> LoadLanguageNames()
{
return typeof(LanguageNames)
.GetRuntimeFields()
.Where(f => f.IsPublic)
.Select(f => (string)f.GetValue(null))
.ToImmutableHashSet();
}
}
}
}
}