public async Task EvaluatesBreakingChangeWhenReturnTypeIsChangedGenericTypeParameter()
        {
            var oldCode = new List <CodeSource>
            {
                new(FieldOnTypeWithMultipleGenericTypeParameters)
            };
            var newCode = new List <CodeSource>
            {
                new(
                    FieldOnTypeWithMultipleGenericTypeParameters.Replace("TKey MyField", "TValue MyField"))
            };

            var options = OptionsFactory.BuildOptions();

            var result = await _calculator.CalculateChanges(oldCode, newCode, options, CancellationToken.None)
                         .ConfigureAwait(false);

            result.ChangeType.Should().Be(SemVerChangeType.Breaking);
        }
Exemplo n.º 2
0
        public async Task EvaluatesBreakingWhenAbstractMethodAdded()
        {
            var oldCode = new List <CodeSource>
            {
                new(NoMethod)
            };
            var newCode = new List <CodeSource>
            {
                new(NoParameters.Replace("public string MyMethod", "public abstract string MyMethod"))
            };

            var options = OptionsFactory.BuildOptions();

            var result = await _calculator.CalculateChanges(oldCode, newCode, options, CancellationToken.None)
                         .ConfigureAwait(false);

            result.ChangeType.Should().Be(SemVerChangeType.Breaking);
        }
Exemplo n.º 3
0
        public async Task EvaluatesChangeOfInterfaceAccessModifiers(
            string oldModifiers,
            string newModifiers,
            SemVerChangeType expected)
        {
            var oldCode = new List <CodeSource>
            {
                new(
                    SingleInterface.Replace("public interface MyInterface", oldModifiers + " interface MyInterface"))
            };
            var newCode = new List <CodeSource>
            {
                new(
                    SingleInterface.Replace("public interface MyInterface", newModifiers + " interface MyInterface"))
            };

            var options = OptionsFactory.BuildOptions();

            var result = await _calculator.CalculateChanges(oldCode, newCode, options, CancellationToken.None)
                         .ConfigureAwait(false);

            result.ChangeType.Should().Be(expected);
        }
        public static ChangeCalculatorResult CalculateChanges(
            this IChangeCalculator calculator,
            IEnumerable <SyntaxNode> oldNodes,
            IEnumerable <SyntaxNode> newNodes,
            ComparerOptions options)
        {
            calculator = calculator ?? throw new ArgumentNullException(nameof(calculator));
            oldNodes   = oldNodes ?? throw new ArgumentNullException(nameof(oldNodes));
            newNodes   = newNodes ?? throw new ArgumentNullException(nameof(newNodes));
            options    = options ?? throw new ArgumentNullException(nameof(options));

            var oldTypes = ResolveDeclaredTypes(oldNodes);
            var newTypes = ResolveDeclaredTypes(newNodes);

            return(calculator.CalculateChanges(oldTypes, newTypes, options));
        }
Exemplo n.º 5
0
        public async Task NoChangeFoundWhenMatchingSameCode()
        {
            var oldCode = new List <CodeSource>
            {
                new(TestNode.ClassProperty),
                new(TestNode.Field)
            };
            var newCode = new List <CodeSource>
            {
                new(TestNode.ClassProperty),
                new(TestNode.Field)
            };

            var options = OptionsFactory.BuildOptions();

            var result = await _calculator.CalculateChanges(oldCode, newCode, options, CancellationToken.None)
                         .ConfigureAwait(false);

            result.ChangeType.Should().Be(SemVerChangeType.None);
        }
Exemplo n.º 6
0
        public async Task EvaluatesAddingGetAccessorWithAccessModifiers(
            string modifiers,
            SemVerChangeType expected)
        {
            var oldCode = new List <CodeSource>
            {
                new(SingleProperty.Replace("get;", string.Empty))
            };
            var newCode = new List <CodeSource>
            {
                new(SingleProperty.Replace("get;", modifiers + " get;"))
            };

            var options = OptionsFactory.BuildOptions();

            var result = await _calculator.CalculateChanges(oldCode, newCode, options, CancellationToken.None)
                         .ConfigureAwait(false);

            result.ChangeType.Should().Be(expected);
        }