-
-
Notifications
You must be signed in to change notification settings - Fork 679
Expand file tree
/
Copy pathWinRTProjection.cs
More file actions
52 lines (46 loc) · 1.54 KB
/
Copy pathWinRTProjection.cs
File metadata and controls
52 lines (46 loc) · 1.54 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// Copyright (c) Fela Ameghino 2015-2026
//
// Distributed under the GNU General Public License v3.0. (See accompanying
// file LICENSE or copy at https://www.gnu.org/licenses/gpl-3.0.txt)
//
using Microsoft.CodeAnalysis;
namespace Telegram.Generators
{
internal static class WinRTProjection
{
// What CsWinRT stamps on a projected type. Matching on these rather than on the namespace,
// because the projection for a referenced WinRT component is generated into the consuming
// assembly: Telegram.Native.Direct2DDevice is a type of this compilation and looks
// managed by every other measure.
private static readonly string[] Attributes =
{
"WindowsRuntimeTypeAttribute",
"ProjectedRuntimeClassAttribute",
"WindowsRuntimeHelperTypeAttribute",
};
public static bool IsProjected(ITypeSymbol type)
{
if (type == null)
{
return false;
}
foreach (var attribute in type.OriginalDefinition.GetAttributes())
{
var declaring = attribute.AttributeClass;
if (declaring?.ContainingNamespace?.Name != "WinRT")
{
continue;
}
foreach (var name in Attributes)
{
if (declaring.Name == name)
{
return true;
}
}
}
return false;
}
}
}