Exemple #1
0
        public void Kind_returns_the_expected_value(string methodName, OperatorKind expectedKind)
        {
            // ARRANGE
            var cs = @"
                using System;

                public class Class1
                {
                    public static Class1 operator +(Class1 other) => throw new NotImplementedException();

                    public static Class1 operator +(Class1 left, Class1 right) => throw new NotImplementedException();

                    public static Class1 operator -(Class1 other) => throw new NotImplementedException();

                    public static Class1 operator -(Class1 left, Class1 right) => throw new NotImplementedException();

                    public static Class1 operator *(Class1 left, Class1 right) => throw new NotImplementedException();

                    public static Class1 operator /(Class1 left, Class1 right) => throw new NotImplementedException();

                    public static Class1 operator %(Class1 left, Class1 right) => throw new NotImplementedException();

                    public static Class1 operator &(Class1 left, Class1 right) => throw new NotImplementedException();

                    public static Class1 operator |(Class1 left, Class1 right) => throw new NotImplementedException();

                    public static Class1 operator !(Class1 left) => throw new NotImplementedException();

                    public static Class1 operator ~(Class1 left) => throw new NotImplementedException();

                    public static Class1 operator ++(Class1 left) => throw new NotImplementedException();

                    public static Class1 operator --(Class1 left) => throw new NotImplementedException();

                    public static bool operator true(Class1 left) => throw new NotImplementedException();

                    public static bool operator false(Class1 left) => throw new NotImplementedException();

                    public static Class1 operator <<(Class1 left, int right) => throw new NotImplementedException();

                    public static Class1 operator >>(Class1 left, int right) => throw new NotImplementedException();

                    public static Class1 operator ^(Class1 left, Class1 right) => throw new NotImplementedException();

                    public static bool operator ==(Class1 left, Class1 right) => throw new NotImplementedException();

                    public static bool operator !=(Class1 left, Class1 right) => throw new NotImplementedException();

                    public static bool operator <(Class1 left, Class1 right) => throw new NotImplementedException();

                    public static bool operator >(Class1 left, Class1 right) => throw new NotImplementedException();

                    public static bool operator <=(Class1 left, Class1 right) => throw new NotImplementedException();

                    public static bool operator >=(Class1 left, Class1 right) => throw new NotImplementedException();

                    public static implicit operator string(Class1 left) => throw new NotImplementedException();

                    public static explicit operator int(Class1 left) => throw new NotImplementedException();
                }
            ";

            using var assembly = Compile(cs);

            var methodDefinition = assembly.MainModule
                                   .Types
                                   .Single(x => x.Name == "Class1")
                                   .Methods
                                   .Single(m => m.Name == methodName);

            using var assemblySetDocumentation = AssemblySetDocumentation.FromAssemblyDefinitions(assembly);
            var assemblyDocumentation = assemblySetDocumentation.Assemblies.Single();
            var typeDocumentation     = assemblyDocumentation.Types.Single();

            // ACT
            var operatorDocumentation = new OperatorDocumentation(
                typeDocumentation,
                new[] { methodDefinition },
                NullXmlDocsProvider.Instance);

            // ASSERT
            Assert.Equal(expectedKind, operatorDocumentation.Kind);
        }
Exemple #2
0
 public async Task <string> RenderDocumentation(OperatorDocumentation documentation) =>
 await this.engine.CompileRenderAsync("operator", documentation);