Commit 29f5236
committed
fix(trimmer): Fix IL3050 warnings around Enum use
When building `src/Uno.UI` with trimmer warnings enabled (and turned up to 11):
dotnet build src/Uno.UI/Uno.UI.Skia.csproj -bl \
-p:TrimmerSingleWarn=false -p:_ExtraTrimmerArgs=--verbose -p:IsTrimmable=true -p:IsAotCompatible=true
One of the warnings is:
src/Uno.UI/UI/Xaml/Internal/InputManager.Pointers.ManagedDirectManip.cs(365,42): error IL3050:
Using member 'System.Enum.GetValues(Type)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling.
It might not be possible to create an array of the enum type at runtime.
Use the GetValues<TEnum> overload or the GetValuesAsUnderlyingType method instead.
Replace use of `System.Enum` methods which take a `Type` parameter
with their generic method overload:
* `Enum.GetName(typeof(T), v)` becomes `Enum.GetName((T)v)`
* `Enum.GetNames(typeof(T))` becomes `Enum.GetNames<T>()`
* `Enum.GetValues(typeof(T))` becomes `Enum.GetValues<T>()`
* `Enum.IsDefined(typeof(T), v)` becomes `Enum.IsDefined((T)v)`
* `Enum.Parse(typeof(T), v)` becomes `Enum.Parse<T>(v)`
This fixes the IL3050 warnings.1 parent 01e90c3 commit 29f5236
File tree
36 files changed
+60
-61
lines changed- src
- SamplesApp
- SamplesApp.UITests/Windows_UI_Xaml_Media/ImageBrushTests
- Uno.UI.Runtime.Skia.Win32/ApplicationMode/DataTransfer
- DragDrop
- Uno.UI.Runtime.Skia.X11/Storage/Pickers
- Uno.UI.RuntimeTests
- MUX
- Input/KeyboardAccelerators
- Microsoft_UI_Xaml_Controls/TeachingTip
- Tests
- Windows_UI_Xaml_Controls
- Windows_UI_Xaml
- Uno.UI/UI/Xaml
- Automation/Peers
- Controls
- Icons
- Primitives/ButtonBase
- TextBox
- Input
- Internal
- Uno.UWP/ApplicationModel/Contacts
36 files changed
+60
-61
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
| 150 | + | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
0 commit comments