Skip to content

Commit 68bc8d4

Browse files
authored
[release/10.0.1xx-rc1] [net10.0] Add UnconditionalSuppressMessage attributes to fix NativeAOT (#31240)
Backport of #31231 to release/10.0.1xx-rc1 /cc @rmarinho
2 parents ba20cbd + 107f8ba commit 68bc8d4

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/Controls/tests/TestCases.HostApp/Issues/Issue21112.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ public class Issue21112ViewModel
9797
{
9898
public ICommand NavigateCommand { get; set; }
9999

100+
[UnconditionalSuppressMessage("TrimAnalysis", "IL2111",
101+
Justification = "The lambda expression in NavigateCommand is only used with known page types that have public parameterless constructors.")]
100102
public Issue21112ViewModel()
101103
{
102104
NavigateCommand = new Command<Type>(async ([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type pageType) =>

src/Controls/tests/TestCases.HostApp/TestCases.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,24 @@ public class TestCaseScreen : CollectionView
99
{
1010
public static Dictionary<string, Action> PageToAction = new Dictionary<string, Action>(StringComparer.OrdinalIgnoreCase);
1111

12+
[UnconditionalSuppressMessage("TrimAnalysis", "IL2112",
13+
Justification = "TestCaseScreen fields are not accessed via reflection in NativeAOT builds since reflection-based test discovery is disabled.")]
1214
bool _filterBugzilla;
15+
16+
[UnconditionalSuppressMessage("TrimAnalysis", "IL2112",
17+
Justification = "TestCaseScreen fields are not accessed via reflection in NativeAOT builds since reflection-based test discovery is disabled.")]
1318
bool _filterNone;
19+
20+
[UnconditionalSuppressMessage("TrimAnalysis", "IL2112",
21+
Justification = "TestCaseScreen fields are not accessed via reflection in NativeAOT builds since reflection-based test discovery is disabled.")]
1422
bool _filterGitHub;
23+
24+
[UnconditionalSuppressMessage("TrimAnalysis", "IL2112",
25+
Justification = "TestCaseScreen fields are not accessed via reflection in NativeAOT builds since reflection-based test discovery is disabled.")]
1526
bool _filterManual;
27+
28+
[UnconditionalSuppressMessage("TrimAnalysis", "IL2112",
29+
Justification = "TestCaseScreen fields are not accessed via reflection in NativeAOT builds since reflection-based test discovery is disabled.")]
1630
string _filter;
1731

1832
void CheckInternetAndLoadPage(Type type)
@@ -88,6 +102,8 @@ Action ActivatePageAndNavigate(IssueAttribute issueAttribute, Type type)
88102
return navigationAction;
89103
}
90104

105+
[UnconditionalSuppressMessage("TrimAnalysis", "IL2026",
106+
Justification = "ActivatePage method is only called in non-NativeAOT builds where reflection-based test discovery is enabled.")]
91107
Page ActivatePage([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type type)
92108
{
93109
var page = Activator.CreateInstance(type) as Page;
@@ -136,6 +152,8 @@ public bool Matches(string filter)
136152
}
137153
}
138154

155+
[UnconditionalSuppressMessage("TrimAnalysis", "IL2112",
156+
Justification = "TestCaseScreen fields are not accessed via reflection in NativeAOT builds since reflection-based test discovery is disabled.")]
139157
readonly List<IssueModel> _issues;
140158

141159
void VerifyNoDuplicates()
@@ -322,6 +340,8 @@ from issueModel in _issues
322340
ItemsSource = issues;
323341
}
324342

343+
[UnconditionalSuppressMessage("TrimAnalysis", "IL2112",
344+
Justification = "TestCaseScreen fields are not accessed via reflection in NativeAOT builds since reflection-based test discovery is disabled.")]
325345
HashSet<string> _exemptNames = new HashSet<string> { };
326346

327347
// Legacy reasons, do not add to this list

0 commit comments

Comments
 (0)