public void MissingTypeFromTypeForwardIsReported() { string forwardedTypeSyntax = @" namespace CompatTests { public class ForwardedTestType { } } "; string leftSyntax = @" [assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(CompatTests.ForwardedTestType))] namespace CompatTests { public class First { } } "; string rightSyntax = @" namespace CompatTests { public class First { } } "; IAssemblySymbol left = SymbolFactory.GetAssemblyFromSyntaxWithReferences(leftSyntax, new[] { forwardedTypeSyntax }); IAssemblySymbol right = SymbolFactory.GetAssemblyFromSyntax(rightSyntax); ApiComparer differ = new(); IEnumerable <CompatDifference> differences = differ.GetDifferences(left, right); CompatDifference[] expected = new[] { new CompatDifference(DiagnosticIds.TypeMustExist, string.Empty, DifferenceType.Removed, "T:CompatTests.ForwardedTestType") }; Assert.Equal(expected, differences); }
public void TypeForwardExistsOnBoth() { string forwardedTypeSyntax = @" namespace CompatTests { public class ForwardedTestType { } } "; string syntax = @" [assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(CompatTests.ForwardedTestType))] namespace CompatTests { public class First { } } "; IEnumerable <string> references = new[] { forwardedTypeSyntax }; IAssemblySymbol left = SymbolFactory.GetAssemblyFromSyntaxWithReferences(syntax, references); IAssemblySymbol right = SymbolFactory.GetAssemblyFromSyntaxWithReferences(syntax, references); ApiComparer differ = new(); Assert.Empty(differ.GetDifferences(new[] { left }, new[] { right })); }