Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTlakaelel Axayakatl Ceja <tlakaelel.ceja@microsoft.com>2021-11-03 01:50:38 +0300
committerGitHub <noreply@github.com>2021-11-03 01:50:38 +0300
commit8e455f03b6a196ea4096f3eacdcc9b146be1e866 (patch)
treed1ee837ac5e9a2ada18a995e62d7c14e4a85dfbe /test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs
parentc702d0337dc1db26a74c482f19a367ad9ddb7b89 (diff)
Test Restructure (#2336)
Move RequiresAssemblyFiles from Analyzer to the linker RequiresCapability file Move the new constraint code from RequiresUnreferencedCode to be on the base Requires file Add Warning Id to messages from the analyzer to distinguish in a test which analyzer missed/found a warning Add RequiresAssemblyFilesMismatchAttribute Title and Message to fix bug Add testing in linker for mismatching attributes Add testing in linker for Delegates in CompilerGenerated file Add support for static constructor compiler-generated calls Add additional warnings from DAM and RUC interaction. Not supported by the analyzer yet
Diffstat (limited to 'test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs')
-rw-r--r--test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs555
1 files changed, 0 insertions, 555 deletions
diff --git a/test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs b/test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs
index a4bdc5be5..7e27f2782 100644
--- a/test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs
+++ b/test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs
@@ -78,29 +78,6 @@ class C
}
[Fact]
- public Task SimpleDiagnosticOnMethod ()
- {
- var TestRequiresAssemblyFilesOnMethod = @"
-using System.Diagnostics.CodeAnalysis;
-
-class C
-{
- [RequiresAssemblyFiles]
- void M1()
- {
- }
-
- void M2()
- {
- M1();
- }
-}";
- return VerifyRequiresAssemblyFilesAnalyzer (TestRequiresAssemblyFilesOnMethod,
- // (13,3): warning IL3002: Using member 'C.M1()' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssemblyFiles).WithSpan (13, 3, 13, 7).WithArguments ("C.M1()", "", ""));
- }
-
- [Fact]
public Task SimpleDiagnosticOnProperty ()
{
var TestRequiresAssemblyFilesOnProperty = @"
@@ -160,29 +137,6 @@ class C
}
[Fact]
- public Task RequiresAssemblyFilesWithMessageAndUrl ()
- {
- var TestRequiresAssemblyFilesWithMessageAndUrl = @"
-using System.Diagnostics.CodeAnalysis;
-
-class C
-{
- [RequiresAssemblyFiles (""Message from attribute"", Url = ""https://helpurl"")]
- void M1()
- {
- }
-
- void M2()
- {
- M1();
- }
-}";
- return VerifyRequiresAssemblyFilesAnalyzer (TestRequiresAssemblyFilesWithMessageAndUrl,
- // (13,3): warning IL3002: Using member 'C.M1()' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. Message from attribute. https://helpurl
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssemblyFiles).WithSpan (13, 3, 13, 7).WithArguments ("C.M1()", " Message from attribute.", " https://helpurl"));
- }
-
- [Fact]
public Task RequiresAssemblyFilesWithUrlOnly ()
{
var TestRequiresAssemblyFilesWithMessageAndUrl = @"
@@ -395,53 +349,6 @@ class C
}
[Fact]
- public Task LazyDelegateWithRequiresAssemblyFiles ()
- {
- const string src = @"
-using System;
-using System.Diagnostics.CodeAnalysis;
-class C
-{
- public static Lazy<C> _default = new Lazy<C>(InitC);
- public static C Default => _default.Value;
-
- [RequiresAssemblyFiles]
- public static C InitC() {
- C cObject = new C();
- return cObject;
- }
-}";
-
- return VerifyRequiresAssemblyFilesAnalyzer (src,
- // (6,50): warning IL3002: Using member 'C.InitC()' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssemblyFiles).WithSpan (6, 50, 6, 55).WithArguments ("C.InitC()", "", ""));
- }
-
- [Fact]
- public Task ActionDelegateWithRequiresAssemblyFiles ()
- {
- const string src = @"
-using System;
-using System.Diagnostics.CodeAnalysis;
-class C
-{
- [RequiresAssemblyFiles]
- public static void M1() { }
- public static void M2()
- {
- Action a = M1;
- Action b = () => M1();
- }
-}";
-
- return VerifyRequiresAssemblyFilesAnalyzer (src,
- // (10,20): warning IL3002: Using member 'C.M1()' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssemblyFiles).WithSpan (10, 20, 10, 22).WithArguments ("C.M1()", "", ""),
- // (11,26): warning IL3002: Using member 'C.M1()' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssemblyFiles).WithSpan (11, 26, 11, 30).WithArguments ("C.M1()", "", ""));
- }
-
- [Fact]
public Task RequiresAssemblyFilesDiagnosticFix ()
{
var test = @"
@@ -767,467 +674,5 @@ public class C
},
fixedExpected: Array.Empty<DiagnosticResult> ());
}
-
- [Fact]
- public Task TestStaticCctorRequiresAssemblyFiles ()
- {
- var src = @"
-using System.Diagnostics.CodeAnalysis;
-
-class StaticCtor
-{
- [RequiresAssemblyFiles (""Message for --TestStaticCtor--"")]
- static StaticCtor ()
- {
- }
-
- static void TestStaticCctorRequiresUnreferencedCode ()
- {
- _ = new StaticCtor ();
- }
-}";
- return VerifyRequiresAssemblyFilesAnalyzer (src);
- }
-
- [Fact]
- public Task StaticCtorTriggeredByFieldAccess ()
- {
- var src = @"
-using System.Diagnostics.CodeAnalysis;
-
-class StaticCtorTriggeredByFieldAccess
-{
- public static int field;
-
- [RequiresAssemblyFiles (""Message for --StaticCtorTriggeredByFieldAccess.Cctor--"")]
- static StaticCtorTriggeredByFieldAccess ()
- {
- field = 0;
- }
-}
-class C
-{
- static void TestStaticCtorMarkingIsTriggeredByFieldAccess ()
- {
- var x = StaticCtorTriggeredByFieldAccess.field + 1;
- }
-}";
- return VerifyRequiresAssemblyFilesAnalyzer (src);
- }
-
- [Fact]
- public Task TestStaticCtorTriggeredByMethodCall ()
- {
- var src = @"
-using System.Diagnostics.CodeAnalysis;
-
-class StaticCtorTriggeredByMethodCall
-{
- [RequiresAssemblyFiles (""Message for --StaticCtorTriggeredByMethodCall.Cctor--"")]
- static StaticCtorTriggeredByMethodCall ()
- {
- }
-
- [RequiresAssemblyFiles (""Message for --StaticCtorTriggeredByMethodCall.TriggerStaticCtorMarking--"")]
- public void TriggerStaticCtorMarking ()
- {
- }
-}
-
-class C
-{
- static void TestStaticCtorTriggeredByMethodCall ()
- {
- new StaticCtorTriggeredByMethodCall ().TriggerStaticCtorMarking ();
- }
-}";
- return VerifyRequiresAssemblyFilesAnalyzer (src,
- // (21,3): warning IL3002: Using member 'StaticCtorTriggeredByMethodCall.TriggerStaticCtorMarking()' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. Message for --StaticCtorTriggeredByMethodCall.TriggerStaticCtorMarking--.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssemblyFiles).WithSpan (21, 3, 21, 69).WithArguments ("StaticCtorTriggeredByMethodCall.TriggerStaticCtorMarking()", " Message for --StaticCtorTriggeredByMethodCall.TriggerStaticCtorMarking--.", "")
- );
- }
-
- [Fact]
- public Task OverrideHasAttributeButBaseDoesnt ()
- {
- var src = @"
-using System.Diagnostics.CodeAnalysis;
-
-class DerivedClass : BaseClass
-{
- [RequiresAssemblyFiles]
- public override void VirtualMethod ()
- {
- }
-
- private string name;
- public override string VirtualPropertyWithAnnotationInAccesor
- {
- [RequiresAssemblyFiles]
- get { return name; }
- set { name = value; }
- }
-
- [RequiresAssemblyFiles]
- public override string VirtualPropertyWithAnnotationInProperty { get; set; }
-}
-
-class BaseClass
-{
- public virtual void VirtualMethod ()
- {
- }
-
- public virtual string VirtualPropertyWithAnnotationInAccesor { get; set; }
-
- public virtual string VirtualPropertyWithAnnotationInProperty { get; set; }
-}";
- return VerifyRequiresAssemblyFilesAnalyzer (src,
- // (7,23): warning IL3003: Member 'DerivedClass.VirtualMethod()' with 'RequiresAssemblyFilesAttribute' overrides base member 'BaseClass.VirtualMethod()' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (7, 23, 7, 36).WithArguments ("Member 'DerivedClass.VirtualMethod()' with 'RequiresAssemblyFilesAttribute' overrides base member 'BaseClass.VirtualMethod()' without 'RequiresAssemblyFilesAttribute'"),
- // (15,3): warning IL3003: Member 'DerivedClass.VirtualPropertyWithAnnotationInAccesor.get' with 'RequiresAssemblyFilesAttribute' overrides base member 'BaseClass.VirtualPropertyWithAnnotationInAccesor.get' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (15, 3, 15, 6).WithArguments ("Member 'DerivedClass.VirtualPropertyWithAnnotationInAccesor.get' with 'RequiresAssemblyFilesAttribute' overrides base member 'BaseClass.VirtualPropertyWithAnnotationInAccesor.get' without 'RequiresAssemblyFilesAttribute'"),
- // (20,25): warning IL3003: Member 'DerivedClass.VirtualPropertyWithAnnotationInProperty' with 'RequiresAssemblyFilesAttribute' overrides base member 'BaseClass.VirtualPropertyWithAnnotationInProperty' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (20, 25, 20, 64).WithArguments ("Member 'DerivedClass.VirtualPropertyWithAnnotationInProperty' with 'RequiresAssemblyFilesAttribute' overrides base member 'BaseClass.VirtualPropertyWithAnnotationInProperty' without 'RequiresAssemblyFilesAttribute'"));
- }
-
- [Fact]
- public Task VirtualHasAttributeButOverrideDoesnt ()
- {
- var src = @"
-using System.Diagnostics.CodeAnalysis;
-
-class DerivedClass : BaseClass
-{
- public override void VirtualMethod ()
- {
- }
-
- private string name;
- public override string VirtualPropertyWithAnnotationInAccesor
- {
- get { return name; }
- set { name = value; }
- }
-
- public override string VirtualPropertyWithAnnotationInProperty { get; set; }
-}
-
-class BaseClass
-{
- [RequiresAssemblyFiles]
- public virtual void VirtualMethod ()
- {
- }
-
- public virtual string VirtualPropertyWithAnnotationInAccesor {[RequiresAssemblyFiles] get; set; }
-
- [RequiresAssemblyFiles]
- public virtual string VirtualPropertyWithAnnotationInProperty { get; set; }
-}";
- return VerifyRequiresAssemblyFilesAnalyzer (src,
- // (6,23): warning IL3003: Base member 'BaseClass.VirtualMethod()' with 'RequiresAssemblyFilesAttribute' has a derived member 'DerivedClass.VirtualMethod()' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (6, 23, 6, 36).WithArguments ("Base member 'BaseClass.VirtualMethod()' with 'RequiresAssemblyFilesAttribute' has a derived member 'DerivedClass.VirtualMethod()' without 'RequiresAssemblyFilesAttribute'"),
- // (13,3): warning IL3003: Base member 'BaseClass.VirtualPropertyWithAnnotationInAccesor.get' with 'RequiresAssemblyFilesAttribute' has a derived member 'DerivedClass.VirtualPropertyWithAnnotationInAccesor.get' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (13, 3, 13, 6).WithArguments ("Base member 'BaseClass.VirtualPropertyWithAnnotationInAccesor.get' with 'RequiresAssemblyFilesAttribute' has a derived member 'DerivedClass.VirtualPropertyWithAnnotationInAccesor.get' without 'RequiresAssemblyFilesAttribute'"),
- // (17,25): warning IL3003: Base member 'BaseClass.VirtualPropertyWithAnnotationInProperty' with 'RequiresAssemblyFilesAttribute' has a derived member 'DerivedClass.VirtualPropertyWithAnnotationInProperty' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (17, 25, 17, 64).WithArguments ("Base member 'BaseClass.VirtualPropertyWithAnnotationInProperty' with 'RequiresAssemblyFilesAttribute' has a derived member 'DerivedClass.VirtualPropertyWithAnnotationInProperty' without 'RequiresAssemblyFilesAttribute'"));
- }
-
- [Fact]
- public Task ImplementationHasAttributeButInterfaceDoesnt ()
- {
- // Once the interface has the attributes indicated in the warnings we would have warnings for AnotherImplementation.
- // In the meantime AnotherImplementation doesn't generate a warning
- var src = @"
-using System.Diagnostics.CodeAnalysis;
-
-class Implementation : IRAF
-{
- [RequiresAssemblyFiles]
- public void Method () { }
-
- private string name;
- public string StringProperty
- {
- [RequiresAssemblyFiles]
- get { return name; }
- set { name = value; }
- }
-
- private int num;
- [RequiresAssemblyFiles]
- public int NumProperty
- {
- get { return num; }
- set { num = value; }
- }
-}
-
-class AnotherImplementation : IRAF
-{
- public void Method () { }
-
- private string name;
- public string StringProperty
- {
- get { return name; }
- set { name = value; }
- }
-
- private int num;
- public int NumProperty
- {
- get { return num; }
- set { num = value; }
- }
-}
-
-class ExplicitImplementation : IRAF
-{
- [RequiresAssemblyFiles]
- void IRAF.Method() { }
-
- private string name;
- string IRAF.StringProperty
- {
- [RequiresAssemblyFiles]
- get { return name; }
- set { name = value; }
- }
-
- private int num;
- [RequiresAssemblyFiles]
- int IRAF.NumProperty
- {
- get { return num; }
- set { num = value; }
- }
-}
-
-interface IRAF
-{
- void Method();
- string StringProperty { get; set; }
- int NumProperty { get; set; }
-}";
- return VerifyRequiresAssemblyFilesAnalyzer (src,
- // (7,14): warning IL3003: Member 'Implementation.Method()' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.Method()' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (7, 14, 7, 20).WithArguments ("Member 'Implementation.Method()' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.Method()' without 'RequiresAssemblyFilesAttribute'"),
- // (13,3): warning IL3003: Member 'Implementation.StringProperty.get' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.StringProperty.get' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (13, 3, 13, 6).WithArguments ("Member 'Implementation.StringProperty.get' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.StringProperty.get' without 'RequiresAssemblyFilesAttribute'"),
- // (19,13): warning IL3003: Member 'Implementation.NumProperty' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.NumProperty' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (19, 13, 19, 24).WithArguments ("Member 'Implementation.NumProperty' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.NumProperty' without 'RequiresAssemblyFilesAttribute'"),
- // (48,12): warning IL3003: Member 'ExplicitImplementation.IRAF.Method()' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.Method()' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (48, 12, 48, 18).WithArguments ("Member 'ExplicitImplementation.IRAF.Method()' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.Method()' without 'RequiresAssemblyFilesAttribute'"),
- // (54,3): warning IL3003: Member 'ExplicitImplementation.IRAF.StringProperty.get' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.StringProperty.get' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (54, 3, 54, 6).WithArguments ("Member 'ExplicitImplementation.IRAF.StringProperty.get' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.StringProperty.get' without 'RequiresAssemblyFilesAttribute'"),
- // (60,11): warning IL3003: Member 'ExplicitImplementation.IRAF.NumProperty' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.NumProperty' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (60, 11, 60, 22).WithArguments ("Member 'ExplicitImplementation.IRAF.NumProperty' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.NumProperty' without 'RequiresAssemblyFilesAttribute'"));
- }
-
- [Fact]
- public Task InterfaceHasAttributeButImplementationDoesnt ()
- {
- var src = @"
-using System.Diagnostics.CodeAnalysis;
-
-class Implementation : IRAF
-{
- public void Method () { }
-
- private string name;
- public string StringProperty
- {
- get { return name; }
- set { name = value; }
- }
-
- private int num;
- public int NumProperty
- {
- get { return num; }
- set { num = value; }
- }
-}
-
-class AnotherImplementation : IRAF
-{
- public void Method () { }
-
- private string name;
- public string StringProperty
- {
- get { return name; }
- set { name = value; }
- }
-
- private int num;
- public int NumProperty
- {
- get { return num; }
- set { num = value; }
- }
-}
-
-interface IRAF
-{
- [RequiresAssemblyFiles]
- void Method();
- string StringProperty { [RequiresAssemblyFiles] get; set; }
- [RequiresAssemblyFiles]
- int NumProperty { get; set; }
-}";
- return VerifyRequiresAssemblyFilesAnalyzer (src,
- // (6,14): warning IL3003: Interface member 'IRAF.Method()' with 'RequiresAssemblyFilesAttribute' has an implementation member 'Implementation.Method()' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (6, 14, 6, 20).WithArguments ("Interface member 'IRAF.Method()' with 'RequiresAssemblyFilesAttribute' has an implementation member 'Implementation.Method()' without 'RequiresAssemblyFilesAttribute'"),
- // (11,3): warning IL3003: Interface member 'IRAF.StringProperty.get' with 'RequiresAssemblyFilesAttribute' has an implementation member 'Implementation.StringProperty.get' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (11, 3, 11, 6).WithArguments ("Interface member 'IRAF.StringProperty.get' with 'RequiresAssemblyFilesAttribute' has an implementation member 'Implementation.StringProperty.get' without 'RequiresAssemblyFilesAttribute'"),
- // (16,13): warning IL3003: Interface member 'IRAF.NumProperty' with 'RequiresAssemblyFilesAttribute' has an implementation member 'Implementation.NumProperty' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (16, 13, 16, 24).WithArguments ("Interface member 'IRAF.NumProperty' with 'RequiresAssemblyFilesAttribute' has an implementation member 'Implementation.NumProperty' without 'RequiresAssemblyFilesAttribute'"),
- // (25,14): warning IL3003: Interface member 'IRAF.Method()' with 'RequiresAssemblyFilesAttribute' has an implementation member 'AnotherImplementation.Method()' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (25, 14, 25, 20).WithArguments ("Interface member 'IRAF.Method()' with 'RequiresAssemblyFilesAttribute' has an implementation member 'AnotherImplementation.Method()' without 'RequiresAssemblyFilesAttribute'"),
- // (30,3): warning IL3003: Interface member 'IRAF.StringProperty.get' with 'RequiresAssemblyFilesAttribute' has an implementation member 'AnotherImplementation.StringProperty.get' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (30, 3, 30, 6).WithArguments ("Interface member 'IRAF.StringProperty.get' with 'RequiresAssemblyFilesAttribute' has an implementation member 'AnotherImplementation.StringProperty.get' without 'RequiresAssemblyFilesAttribute'"),
- // (35,13): warning IL3003: Interface member 'IRAF.NumProperty' with 'RequiresAssemblyFilesAttribute' has an implementation member 'AnotherImplementation.NumProperty' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (35, 13, 35, 24).WithArguments ("Interface member 'IRAF.NumProperty' with 'RequiresAssemblyFilesAttribute' has an implementation member 'AnotherImplementation.NumProperty' without 'RequiresAssemblyFilesAttribute'"));
- }
-
- [Fact]
- public async Task MissingRAFAttributeOnSource ()
- {
- var references = @"
-using System.Diagnostics.CodeAnalysis;
-
-public interface IRAF
-{
- [RequiresAssemblyFiles]
- void Method();
- string StringProperty { [RequiresAssemblyFiles] get; set; }
- [RequiresAssemblyFiles]
- int NumProperty { get; set; }
-}";
-
- var src = @"
-class Implementation : IRAF
-{
- public void Method () { }
-
- private string name;
- public string StringProperty
- {
- get { return name; }
- set { name = value; }
- }
-
- private int num;
- public int NumProperty
- {
- get { return num; }
- set { num = value; }
- }
-}
-
-class AnotherImplementation : IRAF
-{
- public void Method () { }
-
- private string name;
- public string StringProperty
- {
- get { return name; }
- set { name = value; }
- }
-
- private int num;
- public int NumProperty
- {
- get { return num; }
- set { num = value; }
- }
-}
-";
- var compilation = (await TestCaseCompilation.GetCompilation (references)).EmitToImageReference ();
-
- await VerifyRequiresAssemblyFilesAnalyzer (src, additionalReferences: new[] { compilation },
- // (4,14): warning IL3003: Interface member 'IRAF.Method()' with 'RequiresAssemblyFilesAttribute' has an implementation member 'Implementation.Method()' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (4, 14, 4, 20).WithArguments ("Interface member 'IRAF.Method()' with 'RequiresAssemblyFilesAttribute' has an implementation member 'Implementation.Method()' without 'RequiresAssemblyFilesAttribute'"),
- // (9,3): warning IL3003: Interface member 'IRAF.StringProperty.get' with 'RequiresAssemblyFilesAttribute' has an implementation member 'Implementation.StringProperty.get' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (9, 3, 9, 6).WithArguments ("Interface member 'IRAF.StringProperty.get' with 'RequiresAssemblyFilesAttribute' has an implementation member 'Implementation.StringProperty.get' without 'RequiresAssemblyFilesAttribute'"),
- // (14,13): warning IL3003: Interface member 'IRAF.NumProperty' with 'RequiresAssemblyFilesAttribute' has an implementation member 'Implementation.NumProperty' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (14, 13, 14, 24).WithArguments ("Interface member 'IRAF.NumProperty' with 'RequiresAssemblyFilesAttribute' has an implementation member 'Implementation.NumProperty' without 'RequiresAssemblyFilesAttribute'"),
- // (23,14): warning IL3003: Interface member 'IRAF.Method()' with 'RequiresAssemblyFilesAttribute' has an implementation member 'AnotherImplementation.Method()' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (23, 14, 23, 20).WithArguments ("Interface member 'IRAF.Method()' with 'RequiresAssemblyFilesAttribute' has an implementation member 'AnotherImplementation.Method()' without 'RequiresAssemblyFilesAttribute'"),
- // (28,3): warning IL3003: Interface member 'IRAF.StringProperty.get' with 'RequiresAssemblyFilesAttribute' has an implementation member 'AnotherImplementation.StringProperty.get' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (28, 3, 28, 6).WithArguments ("Interface member 'IRAF.StringProperty.get' with 'RequiresAssemblyFilesAttribute' has an implementation member 'AnotherImplementation.StringProperty.get' without 'RequiresAssemblyFilesAttribute'"),
- // (33,13): warning IL3003: Interface member 'IRAF.NumProperty' with 'RequiresAssemblyFilesAttribute' has an implementation member 'AnotherImplementation.NumProperty' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (33, 13, 33, 24).WithArguments ("Interface member 'IRAF.NumProperty' with 'RequiresAssemblyFilesAttribute' has an implementation member 'AnotherImplementation.NumProperty' without 'RequiresAssemblyFilesAttribute'"));
- }
-
- [Fact]
- public async Task MissingRAFAttributeOnReference ()
- {
- var references = @"
-public interface IRAF
-{
- void Method();
- string StringProperty { get; set; }
- int NumProperty { get; set; }
-}";
-
- var src = @"
-using System.Diagnostics.CodeAnalysis;
-
-class Implementation : IRAF
-{
- [RequiresAssemblyFiles]
- public void Method () { }
-
- private string name;
- public string StringProperty
- {
- [RequiresAssemblyFiles]
- get { return name; }
- set { name = value; }
- }
-
- private int num;
- [RequiresAssemblyFiles]
- public int NumProperty
- {
- get { return num; }
- set { num = value; }
- }
-}
-
-class AnotherImplementation : IRAF
-{
- public void Method () { }
-
- private string name;
- public string StringProperty
- {
- get { return name; }
- set { name = value; }
- }
-
- private int num;
- public int NumProperty
- {
- get { return num; }
- set { num = value; }
- }
-}
-";
- var compilation = (await TestCaseCompilation.GetCompilation (references)).EmitToImageReference ();
-
- await VerifyRequiresAssemblyFilesAnalyzer (src, additionalReferences: new[] { compilation },
- // (7,14): warning IL3003: Member 'Implementation.Method()' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.Method()' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (7, 14, 7, 20).WithArguments ("Member 'Implementation.Method()' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.Method()' without 'RequiresAssemblyFilesAttribute'"),
- // (13,3): warning IL3003: Member 'Implementation.StringProperty.get' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.StringProperty.get' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (13, 3, 13, 6).WithArguments ("Member 'Implementation.StringProperty.get' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.StringProperty.get' without 'RequiresAssemblyFilesAttribute'"),
- // (19,13): warning IL3003: Member 'Implementation.NumProperty' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.NumProperty' without 'RequiresAssemblyFilesAttribute'. Attributes must match across all interface implementations or overrides.
- VerifyCS.Diagnostic (DiagnosticId.RequiresAssembyFilesAttributeMismatch).WithSpan (19, 13, 19, 24).WithArguments ("Member 'Implementation.NumProperty' with 'RequiresAssemblyFilesAttribute' implements interface member 'IRAF.NumProperty' without 'RequiresAssemblyFilesAttribute'"));
- }
}
}