blob: a52400284c09a96e84cffb95dca4f65b297927b7 (
plain)
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
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Xunit;
namespace ILLink.RoslynAnalyzer.Tests
{
/// <summary>
/// Test cases stored in files
/// </summary>
public class LinkerTestCases : TestCaseUtils
{
[Theory]
[MemberData (nameof (TestCaseUtils.GetTestData), parameters: nameof (RequiresCapability))]
public void RequiresCapability (string testName, MemberDeclarationSyntax m, List<AttributeSyntax> attrs)
{
if (m is MethodDeclarationSyntax method &&
method.Identifier.ValueText == "TestTypeIsBeforeFieldInit") {
// There is a discrepancy between the way linker and the analyzer represent the location of the error,
// linker will point to the method caller and the analyzer will point to a line of code.
// The TestTypeIsBeforeFieldInit scenario is supported by the analyzer, just the diagnostic message is different
// We verify the analyzer generating the right diagnostic in RequiresUnreferencedCodeAnalyzerTests.cs
return;
}
RunTest<RequiresUnreferencedCodeAnalyzer> (m, attrs, UseMSBuildProperties (MSBuildPropertyOptionNames.EnableTrimAnalyzer));
}
}
}
|