Example #1
0
        public async Task Supports_Generating_Strongly_Typed_WorkDone_Registration_Options()
        {
            var source   = @"
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol.Server.Capabilities;

namespace Test
{
    [GenerateRegistrationOptions(nameof(ServerCapabilities.WorkspaceSymbolProvider), SupportsWorkDoneProgress = true)]
    public partial class WorkspaceSymbolRegistrationOptions { }
}
";
            var expected = @"
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol.Server.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;

#nullable enable
namespace Test
{
    [RegistrationOptionsKey(nameof(ServerCapabilities.WorkspaceSymbolProvider))]
    [RegistrationOptionsConverterAttribute(typeof(WorkspaceSymbolRegistrationOptionsConverter))]
    public partial class WorkspaceSymbolRegistrationOptions : OmniSharp.Extensions.LanguageServer.Protocol.IRegistrationOptions, OmniSharp.Extensions.LanguageServer.Protocol.Models.IWorkDoneProgressOptions
    {
        [Optional]
        public bool WorkDoneProgress
        {
            get;
            set;
        }

        class WorkspaceSymbolRegistrationOptionsConverter : RegistrationOptionsConverterBase<WorkspaceSymbolRegistrationOptions, StaticOptions>
        {
            public WorkspaceSymbolRegistrationOptionsConverter()
            {
            }

            public override StaticOptions Convert(WorkspaceSymbolRegistrationOptions source)
            {
                return new StaticOptions{WorkDoneProgress = source.WorkDoneProgress};
            }
        }

        [RegistrationOptionsKey(nameof(ServerCapabilities.WorkspaceSymbolProvider))]
        public partial class StaticOptions : OmniSharp.Extensions.LanguageServer.Protocol.Models.IWorkDoneProgressOptions
        {
            [Optional]
            public bool WorkDoneProgress
            {
                get;
                set;
            }
        }
    }
}
#nullable restore";
            await GenerationHelpers.AssertGeneratedAsExpected <RegistrationOptionsGenerator>(source, expected);
        }
Example #2
0
        public async Task Auto_Magically_Implements_IEnumLikeString()
        {
            var source   = @"
using OmniSharp.Extensions.JsonRpc.Generation;
namespace Test {
    [StringEnum]
    public readonly partial struct ThreadEventReason
    {
        public static ThreadEventReason Started { get; } = new ThreadEventReason(""started"");
        public static ThreadEventReason Exited { get; } = new ThreadEventReason(""exited"");
    }
}
";
            var expected = @"
#nullable enable
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using Newtonsoft.Json;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Serialization.Converters;

namespace Test
{
    [JsonConverter(typeof(EnumLikeStringConverter))]
    [DebuggerDisplay(""{_value}"")]
    public readonly partial struct ThreadEventReason : IEquatable<string>, IEquatable<ThreadEventReason>, IEnumLikeString
    {
        private static readonly Lazy<IReadOnlyList<ThreadEventReason>> _defaults = new Lazy<IReadOnlyList<ThreadEventReason>>(() =>
        {
            return typeof(ThreadEventReason).GetProperties(BindingFlags.Static | BindingFlags.Public).Where(z => z.Name != nameof(Defaults)).Select(z => z.GetValue(null)).Cast<ThreadEventReason>().ToArray();
        });
        public static IEnumerable<ThreadEventReason> Defaults => _defaults.Value;
        private readonly string _value;
        public ThreadEventReason(string type) => _value = type;
        public static implicit operator ThreadEventReason(string kind) => new ThreadEventReason(kind);
        public static implicit operator string (ThreadEventReason kind) => kind._value;
        public override string ToString() => _value;
        public bool Equals(ThreadEventReason other) => _value == other._value;
        public bool Equals(string other) => _value == other;
        public override bool Equals(object obj) => obj is string s && Equals(s) || obj is ThreadEventReason other && Equals(other);
        public override int GetHashCode() => _value.GetHashCode();
        public static bool operator ==(ThreadEventReason left, ThreadEventReason right) => left.Equals(right);
        public static bool operator !=(ThreadEventReason left, ThreadEventReason right) => !left.Equals(right);
    }
}
#nullable restore";

            CacheKeyHasher.Cache = true;
            await GenerationHelpers.AssertGeneratedAsExpected <EnumLikeStringGenerator>(source, expected);
        }
Example #3
0
        public async Task Auto_Magically_Implements_Properties()
        {
            var source   = @"
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Server.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;

#nullable enable
namespace Test
{
    [Method(""abcd"")]
    public partial class DeclarationParams : TextDocumentPositionParams, IWorkDoneProgressParams, IPartialItemsRequest<LocationOrLocationLinks, LocationOrLocationLink> { }
}
";
            var expected = @"
#nullable enable
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Server.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;

namespace Test
{
    public partial class DeclarationParams
    {
        [Optional]
        public ProgressToken? WorkDoneToken
        {
            get;
            init;
        }

        [Optional]
        public ProgressToken? PartialResultToken
        {
            get;
            init;
        }
    }
}
#nullable restore";

            CacheKeyHasher.Cache = true;
            await GenerationHelpers.AssertGeneratedAsExpected <AutoImplementParamsGenerator>(source, expected);

            await GenerationHelpers.AssertGeneratedAsExpected <AutoImplementParamsGenerator>(source, expected);
        }
        public async Task Supports_Generating_Strongly_Typed_ICanBeResolved_Data()
        {
            var source = @"
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Client;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range;

#nullable enable
namespace OmniSharp.Extensions.LanguageServer.Protocol.Test
{
    /// <summary>
    /// A code lens represents a command that should be shown along with
    /// source text, like the number of references, a way to run tests, etc.
    ///
    /// A code lens is _unresolved_ when no command is associated to it. For performance
    /// reasons the creation of a code lens and resolving should be done in two stages.
    /// </summary>
    [DebuggerDisplay(""{"" + nameof(DebuggerDisplay) + "",nq}"")]
    [Method(TextDocumentNames.CodeLensResolve, Direction.ClientToServer)]
    [GenerateTypedData, GenerateContainer]
    public partial class CodeLens : IRequest<CodeLens>, ICanBeResolved
    {
        /// <summary>
        /// The range in which this code lens is valid. Should only span a single line.
        /// </summary>
        public Range Range { get; set; } = null!;
        [Optional]
        public Command? Command { get; set; }
        /// <summary>
        /// A data entry field that is preserved on a code lens item between
        /// a code lens and a code lens resolve request.
        /// </summary>
        [Optional]
        public JToken? Data { get; set; }
        private string DebuggerDisplay => $""{Range}{( Command != null ? $"" {Command}"" : """" )}"";
        public override string ToString() => DebuggerDisplay;
    }
}
#nullable restore";

            var expected = @"
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Client;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Immutable;
using System.Linq;

#nullable enable
namespace OmniSharp.Extensions.LanguageServer.Protocol.Test
{
    public partial class CodeLens
    {
        public CodeLens<TData> WithData<TData>(TData data)
            where TData : HandlerIdentity? , new()
        {
            return new CodeLens<TData>{Range = Range, Command = Command, Data = data};
        }
    }

    /// <summary>
    /// A code lens represents a command that should be shown along with
    /// source text, like the number of references, a way to run tests, etc.
    ///
    /// A code lens is _unresolved_ when no command is associated to it. For performance
    /// reasons the creation of a code lens and resolving should be done in two stages.
    /// </summary>
    [DebuggerDisplay(""{"" + nameof(DebuggerDisplay) + "",nq}"")]
    [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute, System.Runtime.CompilerServices.CompilerGeneratedAttribute]
    public partial class CodeLens<T> : ICanBeResolved where T : HandlerIdentity? , new()
    {
        /// <summary>
        /// The range in which this code lens is valid. Should only span a single line.
        /// </summary>
        public Range Range
        {
            get;
            set;
        }

        = null !;
        [Optional]
        public Command? Command
        {
            get;
            set;
        }

        /// <summary>
        /// A data entry field that is preserved on a code lens item between
        /// a code lens and a code lens resolve request.
        /// </summary>
        [Optional]
        public T Data
        {
            get => ((ICanBeResolved)this).Data?.ToObject<T>()!;
            set => ((ICanBeResolved)this).Data = JToken.FromObject(value);
        }

        private string DebuggerDisplay => $""{Range}{(Command != null ? $"" {Command}"" : """")}"";
        public override string ToString() => DebuggerDisplay;
        public CodeLens<TData> WithData<TData>(TData data)
            where TData : HandlerIdentity? , new()
        {
            return new CodeLens<TData>{Range = Range, Command = Command, Data = data};
        }

        JToken? ICanBeResolved.Data
        {
            get;
            set;
        }

        private JToken? JData
        {
            get => ((ICanBeResolved)this).Data;
            set => ((ICanBeResolved)this).Data = value;
        }

        public static implicit operator CodeLens<T>(CodeLens value) => new CodeLens<T>{Range = value.Range, Command = value.Command, JData = ((ICanBeResolved)value).Data};
        public static implicit operator CodeLens(CodeLens<T> value) => new CodeLens{Range = value.Range, Command = value.Command, Data = ((ICanBeResolved)value).Data};
    }

    public partial class CodeLensContainer<T> : ContainerBase<CodeLens<T>> where T : HandlerIdentity? , new()
    {
        public CodeLensContainer(): this(Enumerable.Empty<CodeLens<T>>())
        {
        }

        public CodeLensContainer(IEnumerable<CodeLens<T>> items): base(items)
        {
        }

        public CodeLensContainer(params CodeLens<T>[] items): base(items)
        {
        }

        public static implicit operator CodeLensContainer<T>(CodeLens<T>[] items) => new CodeLensContainer<T>(items);
        public static CodeLensContainer<T> Create(params CodeLens<T>[] items) => new CodeLensContainer<T>(items);
        public static implicit operator CodeLensContainer<T>(Collection<CodeLens<T>> items) => new CodeLensContainer<T>(items);
        public static CodeLensContainer<T> Create(Collection<CodeLens<T>> items) => new CodeLensContainer<T>(items);
        public static implicit operator CodeLensContainer<T>(List<CodeLens<T>> items) => new CodeLensContainer<T>(items);
        public static CodeLensContainer<T> Create(List<CodeLens<T>> items) => new CodeLensContainer<T>(items);
        public static implicit operator CodeLensContainer<T>(in ImmutableArray<CodeLens<T>> items) => new CodeLensContainer<T>(items);
        public static CodeLensContainer<T> Create(in ImmutableArray<CodeLens<T>> items) => new CodeLensContainer<T>(items);
        public static implicit operator CodeLensContainer<T>(ImmutableList<CodeLens<T>> items) => new CodeLensContainer<T>(items);
        public static CodeLensContainer<T> Create(ImmutableList<CodeLens<T>> items) => new CodeLensContainer<T>(items);
        public static implicit operator CodeLensContainer(CodeLensContainer<T> container) => new CodeLensContainer(container.Select(z => (CodeLens)z));
    }
}
#nullable restore

";
            await GenerationHelpers.AssertGeneratedAsExpected <StronglyTypedGenerator>(source, expected);
        }
Example #5
0
        public async Task Supports_Generating_Strongly_Typed_Registration_Options_With_Converters()
        {
            var source = @"
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Client;
using OmniSharp.Extensions.LanguageServer.Protocol.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range;

#nullable enable
namespace OmniSharp.Extensions.LanguageServer.Protocol.Test
{
    [GenerateRegistrationOptions(nameof(ServerCapabilities.CodeActionProvider)]
    [RegistrationOptionsConverter(typeof(CodeActionRegistrationOptionsConverter))]
    public partial class CodeActionRegistrationOptions : ITextDocumentRegistrationOptions, IWorkDoneProgressOptions
    {
        /// <summary>
        /// CodeActionKinds that this server may return.
        ///
        /// The list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server
        /// may list out every specific kind they provide.
        /// </summary>
        [Optional]
        public Container<CodeActionKind>? CodeActionKinds { get; set; } = new Container<CodeActionKind>();

        /// <summary>
        /// The server provides support to resolve additional
        /// information for a code action.
        ///
        /// @since 3.16.0
        /// </summary>
        [Optional]
        public bool ResolveProvider { get; set; }

        class CodeActionRegistrationOptionsConverter : RegistrationOptionsConverterBase<CodeActionRegistrationOptions, StaticCodeActionRegistrationOptions>
        {
            private readonly IHandlersManager _handlersManager;

            public Converter(IHandlersManager handlersManager)
            {
                _handlersManager = handlersManager;
            }

            public override StaticCodeActionRegistrationOptions Convert(CodeActionRegistrationOptions source)
            {
                return new StaticCodeActionRegistrationOptions {
                    CodeActionKinds = source.CodeActionKinds,
                    ResolveProvider = source.ResolveProvider || _handlersManager.Descriptors.Any(z => z.HandlerType == typeof(ICodeActionResolveHandler)),
                    WorkDoneProgress = source.WorkDoneProgress,
                };
            }
        }
    }
}
#nullable restore";

            var expected = @"
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Client;
using OmniSharp.Extensions.LanguageServer.Protocol.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range;
using OmniSharp.Extensions.LanguageServer.Protocol.Server.Capabilities;

#nullable enable
namespace OmniSharp.Extensions.LanguageServer.Protocol.Test
{
    [RegistrationOptionsKey(nameof(ServerCapabilities.CodeActionProvider))]
    public partial class CodeActionRegistrationOptions : OmniSharp.Extensions.LanguageServer.Protocol.IRegistrationOptions
    {
        public DocumentSelector? DocumentSelector
        {
            get;
            set;
        }

        [Optional]
        public bool WorkDoneProgress
        {
            get;
            set;
        }

        [RegistrationOptionsKey(nameof(ServerCapabilities.CodeActionProvider))]
        public partial class StaticOptions : IWorkDoneProgressOptions
        {
            /// <summary>
            /// CodeActionKinds that this server may return.
            ///
            /// The list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server
            /// may list out every specific kind they provide.
            /// </summary>
            [Optional]
            public Container<CodeActionKind>? CodeActionKinds
            {
                get;
                set;
            }

            = new Container<CodeActionKind>();
            /// <summary>
            /// The server provides support to resolve additional
            /// information for a code action.
            ///
            /// @since 3.16.0
            /// </summary>
            [Optional]
            public bool ResolveProvider
            {
                get;
                set;
            }

            [Optional]
            public bool WorkDoneProgress
            {
                get;
                set;
            }
        }
    }
}
#nullable restore";
            await GenerationHelpers.AssertGeneratedAsExpected <RegistrationOptionsGenerator>(source, expected);
        }
Example #6
0
        public async Task Supports_Generating_Void_Task_Return()
        {
            var source = @"
// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated a code generator.
// </auto-generated>
// ------------------------------------------------------------------------------

using MediatR;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Client;
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;

#nullable enable
namespace Lsp.Tests.Integration.Fixtures
{
    [Parallel]
    [Method(ClientNames.RegisterCapability, Direction.ServerToClient)]
    [
        GenerateHandler(""OmniSharp.Extensions.LanguageServer.Protocol.Client"", Name = ""RegisterCapability""),
        GenerateHandlerMethods(typeof(ILanguageClientRegistry),
        GenerateRequestMethods(typeof(IClientLanguageServer), typeof(ILanguageServer))
    ]
    public class RegistrationParams : IJsonRpcRequest
    {
        public RegistrationContainer Registrations { get; set; } = null!;
    }

    /// <summary>
    /// General parameters to to regsiter for a capability.
    /// </summary>
    [DebuggerDisplay(""{"" + nameof(DebuggerDisplay) + "",nq}"")]
    [GenerateContainer]
    public partial class Registration
    {
    }
}
#nullable restore";

            var expectedHandlers = @"
using Lsp.Tests.Integration.Fixtures;
using MediatR;
using Microsoft.Extensions.DependencyInjection;
using OmniSharp.Extensions.DebugAdapter.Protocol;
using OmniSharp.Extensions.DebugAdapter.Protocol.Events;
using OmniSharp.Extensions.DebugAdapter.Protocol.Models;
using OmniSharp.Extensions.DebugAdapter.Protocol.Requests;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Client;
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

#nullable enable
namespace OmniSharp.Extensions.LanguageServer.Protocol.Client
{
    [Parallel, Method(ClientNames.RegisterCapability, Direction.ServerToClient)]
    [System.Runtime.CompilerServices.CompilerGeneratedAttribute]
    public partial interface IRegisterCapabilityHandler : IJsonRpcRequestHandler<RegistrationParams, MediatR.Unit>
    {
    }

    [System.Runtime.CompilerServices.CompilerGeneratedAttribute, System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute]
    abstract public partial class RegisterCapabilityHandlerBase : AbstractHandlers.Request<RegistrationParams, MediatR.Unit>, IRegisterCapabilityHandler
    {
    }
}
#nullable restore

namespace OmniSharp.Extensions.LanguageServer.Protocol.Client
{
#nullable enable
    [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute, System.Runtime.CompilerServices.CompilerGeneratedAttribute]
    public static partial class RegisterCapabilityExtensions
    {
        public static ILanguageClientRegistry OnRegisterCapability(this ILanguageClientRegistry registry, Func<RegistrationParams, Task> handler) => registry.AddHandler(ClientNames.RegisterCapability, new DelegatingHandlers.Request<RegistrationParams>(HandlerAdapter.Adapt<RegistrationParams>(handler)));
        public static ILanguageClientRegistry OnRegisterCapability(this ILanguageClientRegistry registry, Func<RegistrationParams, CancellationToken, Task> handler) => registry.AddHandler(ClientNames.RegisterCapability, new DelegatingHandlers.Request<RegistrationParams>(HandlerAdapter.Adapt<RegistrationParams>(handler)));
    }
#nullable restore
}";
            await GenerationHelpers.AssertGeneratedAsExpected <GenerateHandlerMethodsGenerator>(source, expectedHandlers);
        }
Example #7
0
        public async Task Supports_Params_Type_As_Source()
        {
            var source   = FeatureFixture.ReadSource("Workspace.WorkspaceSymbolsFeature.cs");
            var expected = @"
using MediatR;
using Microsoft.Extensions.DependencyInjection;
using OmniSharp.Extensions.DebugAdapter.Protocol;
using OmniSharp.Extensions.DebugAdapter.Protocol.Events;
using OmniSharp.Extensions.DebugAdapter.Protocol.Models;
using OmniSharp.Extensions.DebugAdapter.Protocol.Requests;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Client;
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Progress;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using OmniSharp.Extensions.LanguageServer.Protocol.Server.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Workspace;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;

#nullable enable
namespace OmniSharp.Extensions.LanguageServer.Protocol.Workspace
{
    [Parallel, Method(WorkspaceNames.WorkspaceSymbol, Direction.ClientToServer)]
    [System.Runtime.CompilerServices.CompilerGeneratedAttribute]
    public partial interface IWorkspaceSymbolsHandler : IJsonRpcRequestHandler<WorkspaceSymbolParams, Container<SymbolInformation>?>, IRegistration<WorkspaceSymbolRegistrationOptions, WorkspaceSymbolCapability>
    {
    }

    [System.Runtime.CompilerServices.CompilerGeneratedAttribute, System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute]
    abstract public partial class WorkspaceSymbolsHandlerBase : AbstractHandlers.Request<WorkspaceSymbolParams, Container<SymbolInformation>?, WorkspaceSymbolRegistrationOptions, WorkspaceSymbolCapability>, IWorkspaceSymbolsHandler
    {
    }

    [System.Runtime.CompilerServices.CompilerGeneratedAttribute, System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute]
    abstract public partial class WorkspaceSymbolsPartialHandlerBase : AbstractHandlers.PartialResults<WorkspaceSymbolParams, Container<SymbolInformation>?, SymbolInformation, WorkspaceSymbolRegistrationOptions, WorkspaceSymbolCapability>, IWorkspaceSymbolsHandler
    {
        protected WorkspaceSymbolsPartialHandlerBase(System.Guid id, IProgressManager progressManager): base(progressManager, Container<SymbolInformation>.From)
        {
        }
    }
}
#nullable restore

namespace OmniSharp.Extensions.LanguageServer.Protocol.Workspace
{
#nullable enable
    [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute, System.Runtime.CompilerServices.CompilerGeneratedAttribute]
    public static partial class WorkspaceSymbolsExtensions
    {
        public static ILanguageServerRegistry OnWorkspaceSymbols(this ILanguageServerRegistry registry, Func<WorkspaceSymbolParams, Task<Container<SymbolInformation>?>> handler, RegistrationOptionsDelegate<WorkspaceSymbolRegistrationOptions, WorkspaceSymbolCapability> registrationOptions)
        {
            return registry.AddHandler(WorkspaceNames.WorkspaceSymbol, new LanguageProtocolDelegatingHandlers.Request<WorkspaceSymbolParams, Container<SymbolInformation>?, WorkspaceSymbolRegistrationOptions, WorkspaceSymbolCapability>(HandlerAdapter<WorkspaceSymbolCapability>.Adapt<WorkspaceSymbolParams, Container<SymbolInformation>?>(handler), RegistrationAdapter<WorkspaceSymbolCapability>.Adapt<WorkspaceSymbolRegistrationOptions>(registrationOptions)));
        }

        public static ILanguageServerRegistry OnWorkspaceSymbols(this ILanguageServerRegistry registry, Func<WorkspaceSymbolParams, CancellationToken, Task<Container<SymbolInformation>?>> handler, RegistrationOptionsDelegate<WorkspaceSymbolRegistrationOptions, WorkspaceSymbolCapability> registrationOptions)
        {
            return registry.AddHandler(WorkspaceNames.WorkspaceSymbol, new LanguageProtocolDelegatingHandlers.Request<WorkspaceSymbolParams, Container<SymbolInformation>?, WorkspaceSymbolRegistrationOptions, WorkspaceSymbolCapability>(HandlerAdapter<WorkspaceSymbolCapability>.Adapt<WorkspaceSymbolParams, Container<SymbolInformation>?>(handler), RegistrationAdapter<WorkspaceSymbolCapability>.Adapt<WorkspaceSymbolRegistrationOptions>(registrationOptions)));
        }

        public static ILanguageServerRegistry OnWorkspaceSymbols(this ILanguageServerRegistry registry, Func<WorkspaceSymbolParams, WorkspaceSymbolCapability, CancellationToken, Task<Container<SymbolInformation>?>> handler, RegistrationOptionsDelegate<WorkspaceSymbolRegistrationOptions, WorkspaceSymbolCapability> registrationOptions)
        {
            return registry.AddHandler(WorkspaceNames.WorkspaceSymbol, new LanguageProtocolDelegatingHandlers.Request<WorkspaceSymbolParams, Container<SymbolInformation>?, WorkspaceSymbolRegistrationOptions, WorkspaceSymbolCapability>(HandlerAdapter<WorkspaceSymbolCapability>.Adapt<WorkspaceSymbolParams, Container<SymbolInformation>?>(handler), RegistrationAdapter<WorkspaceSymbolCapability>.Adapt<WorkspaceSymbolRegistrationOptions>(registrationOptions)));
        }

        public static ILanguageServerRegistry ObserveWorkspaceSymbols(this ILanguageServerRegistry registry, Action<WorkspaceSymbolParams, IObserver<IEnumerable<SymbolInformation>>> handler, RegistrationOptionsDelegate<WorkspaceSymbolRegistrationOptions, WorkspaceSymbolCapability> registrationOptions)
        {
            return registry.AddHandler(WorkspaceNames.WorkspaceSymbol, _ => new LanguageProtocolDelegatingHandlers.PartialResults<WorkspaceSymbolParams, Container<SymbolInformation>?, SymbolInformation, WorkspaceSymbolRegistrationOptions, WorkspaceSymbolCapability>(PartialAdapter<WorkspaceSymbolCapability>.Adapt<WorkspaceSymbolParams, SymbolInformation>(handler), RegistrationAdapter<WorkspaceSymbolCapability>.Adapt<WorkspaceSymbolRegistrationOptions>(registrationOptions), _.GetService<IProgressManager>(), Container<SymbolInformation>.From));
        }

        public static ILanguageServerRegistry ObserveWorkspaceSymbols(this ILanguageServerRegistry registry, Action<WorkspaceSymbolParams, IObserver<IEnumerable<SymbolInformation>>, CancellationToken> handler, RegistrationOptionsDelegate<WorkspaceSymbolRegistrationOptions, WorkspaceSymbolCapability> registrationOptions)
        {
            return registry.AddHandler(WorkspaceNames.WorkspaceSymbol, _ => new LanguageProtocolDelegatingHandlers.PartialResults<WorkspaceSymbolParams, Container<SymbolInformation>?, SymbolInformation, WorkspaceSymbolRegistrationOptions, WorkspaceSymbolCapability>(PartialAdapter<WorkspaceSymbolCapability>.Adapt<WorkspaceSymbolParams, SymbolInformation>(handler), RegistrationAdapter<WorkspaceSymbolCapability>.Adapt<WorkspaceSymbolRegistrationOptions>(registrationOptions), _.GetService<IProgressManager>(), Container<SymbolInformation>.From));
        }

        public static ILanguageServerRegistry ObserveWorkspaceSymbols(this ILanguageServerRegistry registry, Action<WorkspaceSymbolParams, IObserver<IEnumerable<SymbolInformation>>, WorkspaceSymbolCapability, CancellationToken> handler, RegistrationOptionsDelegate<WorkspaceSymbolRegistrationOptions, WorkspaceSymbolCapability> registrationOptions)
        {
            return registry.AddHandler(WorkspaceNames.WorkspaceSymbol, _ => new LanguageProtocolDelegatingHandlers.PartialResults<WorkspaceSymbolParams, Container<SymbolInformation>?, SymbolInformation, WorkspaceSymbolRegistrationOptions, WorkspaceSymbolCapability>(PartialAdapter<WorkspaceSymbolCapability>.Adapt<WorkspaceSymbolParams, SymbolInformation>(handler), RegistrationAdapter<WorkspaceSymbolCapability>.Adapt<WorkspaceSymbolRegistrationOptions>(registrationOptions), _.GetService<IProgressManager>(), Container<SymbolInformation>.From));
        }

        public static IRequestProgressObservable<IEnumerable<SymbolInformation>, Container<SymbolInformation>?> RequestWorkspaceSymbols(this ITextDocumentLanguageClient mediator, WorkspaceSymbolParams request, CancellationToken cancellationToken = default) => mediator.ProgressManager.MonitorUntil(request, value => new Container<SymbolInformation>(value), cancellationToken);
        public static IRequestProgressObservable<IEnumerable<SymbolInformation>, Container<SymbolInformation>?> RequestWorkspaceSymbols(this ILanguageClient mediator, WorkspaceSymbolParams request, CancellationToken cancellationToken = default) => mediator.ProgressManager.MonitorUntil(request, value => new Container<SymbolInformation>(value), cancellationToken);
    }
#nullable restore
}";
            await GenerationHelpers.AssertGeneratedAsExpected <GenerateHandlerMethodsGenerator>(source, expected);
        }
Example #8
0
        public async Task Supports_Generating_Custom_Language_Extensions()
        {
            var source = @"
// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated a code generator.
// </auto-generated>
// ------------------------------------------------------------------------------

using MediatR;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Client;
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;

#nullable enable
namespace Lsp.Tests.Integration.Fixtures
{
    [Parallel, Method(""tests/run"", Direction.ClientToServer)]
    [
        GenerateHandler,
        GenerateHandlerMethods(typeof(ILanguageServerRegistry)),
        GenerateRequestMethods(typeof(ILanguageClient))
    ]
    [RegistrationOptions(typeof(UnitTestRegistrationOptions)), Capability(typeof(UnitTestCapability))]
    public partial class UnitTest : IRequest
    {
        public string Name { get; set; } = null!;
    }

    [Parallel, Method(""tests/discover"", Direction.ClientToServer)]
    [
        GenerateHandler,
        GenerateHandlerMethods(typeof(ILanguageServerRegistry)),
        GenerateRequestMethods(typeof(ILanguageClient))
    ]
    [RegistrationOptions(typeof(UnitTestRegistrationOptions)), Capability(typeof(UnitTestCapability))]
    public partial class DiscoverUnitTestsParams : IPartialItemsRequest<Container<UnitTest>, UnitTest>, IWorkDoneProgressParams
    {
        public ProgressToken? PartialResultToken { get; set; } = null!;
        public ProgressToken? WorkDoneToken { get; set; } = null!;
    }

    [CapabilityKey(""workspace"", ""unitTests"")]
    public partial class UnitTestCapability : DynamicCapability
    {
        public string Property { get; set; } = null!;
    }

    [GenerateRegistrationOptions(""unitTestDiscovery"")]
    public partial class UnitTestRegistrationOptions : IWorkDoneProgressOptions
    {
        [Optional] public bool SupportsDebugging { get; set; }
    }
}
#nullable restore";

            var expectedOptions     = @"
using MediatR;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Client;
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using OmniSharp.Extensions.LanguageServer.Protocol.Server.Capabilities;

#nullable enable
namespace Lsp.Tests.Integration.Fixtures
{
    [RegistrationOptionsKey(""unitTestDiscovery"")]
    [RegistrationOptionsConverterAttribute(typeof(UnitTestRegistrationOptionsConverter))]
    public partial class UnitTestRegistrationOptions : OmniSharp.Extensions.LanguageServer.Protocol.IRegistrationOptions
    {
        [Optional]
        public bool WorkDoneProgress
        {
            get;
            set;
        }

        class UnitTestRegistrationOptionsConverter : RegistrationOptionsConverterBase<UnitTestRegistrationOptions, StaticOptions>
        {
            public UnitTestRegistrationOptionsConverter()
            {
            }

            public override StaticOptions Convert(UnitTestRegistrationOptions source)
            {
                return new StaticOptions{SupportsDebugging = source.SupportsDebugging, WorkDoneProgress = source.WorkDoneProgress};
            }
        }

        [RegistrationOptionsKey(""unitTestDiscovery"")]
        public partial class StaticOptions : IWorkDoneProgressOptions
        {
            [Optional]
            public bool SupportsDebugging
            {
                get;
                set;
            }

            [Optional]
            public bool WorkDoneProgress
            {
                get;
                set;
            }
        }
    }
}
#nullable restore";
            var expectedStrongTypes = @"
using MediatR;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Client;
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;

#nullable enable
namespace Lsp.Tests.Integration.Fixtures
{
    [Parallel, Method(""tests/run"", Direction.ClientToServer)]
    [
        GenerateHandler,
        GenerateHandlerMethods(typeof(ILanguageServerRegistry)),
        GenerateRequestMethods(typeof(ILanguageClient))
    ]
    [RegistrationOptions(typeof(UnitTestRegistrationOptions)), Capability(typeof(UnitTestCapability))]
    public partial class UnitTest : IRequest
    {
        public string Name { get; set; } = null!;
    }

    [Parallel, Method(""tests/discover"", Direction.ClientToServer)]
    [
        GenerateHandler,
        GenerateHandlerMethods(typeof(ILanguageServerRegistry)),
        GenerateRequestMethods(typeof(ILanguageClient))
    ]
    [RegistrationOptions(typeof(UnitTestRegistrationOptions)), Capability(typeof(UnitTestCapability))]
    public partial class DiscoverUnitTestsParams : IPartialItemsRequest<Container<UnitTest>, UnitTest>, IWorkDoneProgressParams
    {
        public ProgressToken? PartialResultToken { get; set; } = null!;
        public ProgressToken? WorkDoneToken { get; set; } = null!;
    }

    [CapabilityKey(""workspace"", ""unitTests"")]
    public partial class UnitTestCapability : DynamicCapability
    {
        public string Property { get; set; } = null!;
    }

    [GenerateRegistrationOptions(""unitTestDiscovery"")]
    public partial class UnitTestRegistrationOptions : IWorkDoneProgressOptions
    {
        [Optional] public bool SupportsDebugging { get; set; }
    }
}
#nullable restore
";
            var expectedHandlers    = @"
using Lsp.Tests.Integration.Fixtures;
using MediatR;
using Microsoft.Extensions.DependencyInjection;
using OmniSharp.Extensions.DebugAdapter.Protocol;
using OmniSharp.Extensions.DebugAdapter.Protocol.Events;
using OmniSharp.Extensions.DebugAdapter.Protocol.Models;
using OmniSharp.Extensions.DebugAdapter.Protocol.Requests;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Client;
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Progress;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

#nullable enable
namespace Lsp.Tests.Integration.Fixtures
{
    [Parallel, Method(""tests/discover"", Direction.ClientToServer)]
    [System.Runtime.CompilerServices.CompilerGeneratedAttribute]
    public partial interface IDiscoverUnitTestsHandler : IJsonRpcRequestHandler<DiscoverUnitTestsParams, Container<UnitTest>>, IRegistration<UnitTestRegistrationOptions, UnitTestCapability>
    {
    }

    [System.Runtime.CompilerServices.CompilerGeneratedAttribute, System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute]
    abstract public partial class DiscoverUnitTestsHandlerBase : AbstractHandlers.Request<DiscoverUnitTestsParams, Container<UnitTest>, UnitTestRegistrationOptions, UnitTestCapability>, IDiscoverUnitTestsHandler
    {
    }

    [System.Runtime.CompilerServices.CompilerGeneratedAttribute, System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute]
    abstract public partial class DiscoverUnitTestsPartialHandlerBase : AbstractHandlers.PartialResults<DiscoverUnitTestsParams, Container<UnitTest>, UnitTest, UnitTestRegistrationOptions, UnitTestCapability>, IDiscoverUnitTestsHandler
    {
        protected DiscoverUnitTestsPartialHandlerBase(System.Guid id, IProgressManager progressManager): base(progressManager, Container<UnitTest>.From)
        {
        }
    }
}
#nullable restore

namespace Lsp.Tests.Integration.Fixtures
{
#nullable enable
    [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute, System.Runtime.CompilerServices.CompilerGeneratedAttribute]
    public static partial class DiscoverUnitTestsExtensions
    {
        public static ILanguageServerRegistry OnDiscoverUnitTests(this ILanguageServerRegistry registry, Func<DiscoverUnitTestsParams, Task<Container<UnitTest>>> handler, RegistrationOptionsDelegate<UnitTestRegistrationOptions, UnitTestCapability> registrationOptions)
        {
            return registry.AddHandler(""tests/discover"", new LanguageProtocolDelegatingHandlers.Request<DiscoverUnitTestsParams, Container<UnitTest>, UnitTestRegistrationOptions, UnitTestCapability>(HandlerAdapter<UnitTestCapability>.Adapt<DiscoverUnitTestsParams, Container<UnitTest>>(handler), RegistrationAdapter<UnitTestCapability>.Adapt<UnitTestRegistrationOptions>(registrationOptions)));
        }

        public static ILanguageServerRegistry OnDiscoverUnitTests(this ILanguageServerRegistry registry, Func<DiscoverUnitTestsParams, CancellationToken, Task<Container<UnitTest>>> handler, RegistrationOptionsDelegate<UnitTestRegistrationOptions, UnitTestCapability> registrationOptions)
        {
            return registry.AddHandler(""tests/discover"", new LanguageProtocolDelegatingHandlers.Request<DiscoverUnitTestsParams, Container<UnitTest>, UnitTestRegistrationOptions, UnitTestCapability>(HandlerAdapter<UnitTestCapability>.Adapt<DiscoverUnitTestsParams, Container<UnitTest>>(handler), RegistrationAdapter<UnitTestCapability>.Adapt<UnitTestRegistrationOptions>(registrationOptions)));
        }

        public static ILanguageServerRegistry OnDiscoverUnitTests(this ILanguageServerRegistry registry, Func<DiscoverUnitTestsParams, UnitTestCapability, CancellationToken, Task<Container<UnitTest>>> handler, RegistrationOptionsDelegate<UnitTestRegistrationOptions, UnitTestCapability> registrationOptions)
        {
            return registry.AddHandler(""tests/discover"", new LanguageProtocolDelegatingHandlers.Request<DiscoverUnitTestsParams, Container<UnitTest>, UnitTestRegistrationOptions, UnitTestCapability>(HandlerAdapter<UnitTestCapability>.Adapt<DiscoverUnitTestsParams, Container<UnitTest>>(handler), RegistrationAdapter<UnitTestCapability>.Adapt<UnitTestRegistrationOptions>(registrationOptions)));
        }

        public static ILanguageServerRegistry ObserveDiscoverUnitTests(this ILanguageServerRegistry registry, Action<DiscoverUnitTestsParams, IObserver<IEnumerable<UnitTest>>> handler, RegistrationOptionsDelegate<UnitTestRegistrationOptions, UnitTestCapability> registrationOptions)
        {
            return registry.AddHandler(""tests/discover"", _ => new LanguageProtocolDelegatingHandlers.PartialResults<DiscoverUnitTestsParams, Container<UnitTest>, UnitTest, UnitTestRegistrationOptions, UnitTestCapability>(PartialAdapter<UnitTestCapability>.Adapt<DiscoverUnitTestsParams, UnitTest>(handler), RegistrationAdapter<UnitTestCapability>.Adapt<UnitTestRegistrationOptions>(registrationOptions), _.GetService<IProgressManager>(), Container<UnitTest>.From));
        }

        public static ILanguageServerRegistry ObserveDiscoverUnitTests(this ILanguageServerRegistry registry, Action<DiscoverUnitTestsParams, IObserver<IEnumerable<UnitTest>>, CancellationToken> handler, RegistrationOptionsDelegate<UnitTestRegistrationOptions, UnitTestCapability> registrationOptions)
        {
            return registry.AddHandler(""tests/discover"", _ => new LanguageProtocolDelegatingHandlers.PartialResults<DiscoverUnitTestsParams, Container<UnitTest>, UnitTest, UnitTestRegistrationOptions, UnitTestCapability>(PartialAdapter<UnitTestCapability>.Adapt<DiscoverUnitTestsParams, UnitTest>(handler), RegistrationAdapter<UnitTestCapability>.Adapt<UnitTestRegistrationOptions>(registrationOptions), _.GetService<IProgressManager>(), Container<UnitTest>.From));
        }

        public static ILanguageServerRegistry ObserveDiscoverUnitTests(this ILanguageServerRegistry registry, Action<DiscoverUnitTestsParams, IObserver<IEnumerable<UnitTest>>, UnitTestCapability, CancellationToken> handler, RegistrationOptionsDelegate<UnitTestRegistrationOptions, UnitTestCapability> registrationOptions)
        {
            return registry.AddHandler(""tests/discover"", _ => new LanguageProtocolDelegatingHandlers.PartialResults<DiscoverUnitTestsParams, Container<UnitTest>, UnitTest, UnitTestRegistrationOptions, UnitTestCapability>(PartialAdapter<UnitTestCapability>.Adapt<DiscoverUnitTestsParams, UnitTest>(handler), RegistrationAdapter<UnitTestCapability>.Adapt<UnitTestRegistrationOptions>(registrationOptions), _.GetService<IProgressManager>(), Container<UnitTest>.From));
        }

        public static IRequestProgressObservable<IEnumerable<UnitTest>, Container<UnitTest>> RequestDiscoverUnitTests(this ILanguageClient mediator, DiscoverUnitTestsParams request, CancellationToken cancellationToken = default) => mediator.ProgressManager.MonitorUntil(request, value => new Container<UnitTest>(value), cancellationToken);
    }
#nullable restore
}";
            await GenerationHelpers.AssertGeneratedAsExpected <RegistrationOptionsGenerator>(source, expectedOptions);

            await GenerationHelpers.AssertGeneratedAsExpected <StronglyTypedGenerator>(source, expectedStrongTypes);

            await GenerationHelpers.AssertGeneratedAsExpected <GenerateHandlerMethodsGenerator>(source, expectedHandlers);
        }
Example #9
0
        public async Task Supports_Generating_Strongly_Typed_Container()
        {
            var source = @"
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Client;
using OmniSharp.Extensions.LanguageServer.Protocol.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range;

#nullable enable
namespace OmniSharp.Extensions.LanguageServer.Protocol.Test
{
    /// <summary>
    /// A code lens represents a command that should be shown along with
    /// source text, like the number of references, a way to run tests, etc.
    ///
    /// A code lens is _unresolved_ when no command is associated to it. For performance
    /// reasons the creation of a code lens and resolving should be done in two stages.
    /// </summary>
    [DebuggerDisplay(""{"" + nameof(DebuggerDisplay) + "",nq}"")]
    [Method(TextDocumentNames.CodeLensResolve, Direction.ClientToServer)]
    [GenerateContainer]
    public partial class CodeLens : IRequest<CodeLens>, ICanBeResolved
    {
        /// <summary>
        /// The range in which this code lens is valid. Should only span a single line.
        /// </summary>
        public Range Range { get; set; } = null!;
        [Optional]
        public Command? Command { get; set; }
        /// <summary>
        /// A data entry field that is preserved on a code lens item between
        /// a code lens and a code lens resolve request.
        /// </summary>
        [Optional]
        public JToken? Data { get; init; }
        private string DebuggerDisplay => $""{Range}{( Command != null ? $"" {Command}"" : """" )}"";
        public override string ToString() => DebuggerDisplay;
    }
}
#nullable restore";

            var expected = @"using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Client;
using OmniSharp.Extensions.LanguageServer.Protocol.Generation;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Immutable;
using System.Linq;

#nullable enable
namespace OmniSharp.Extensions.LanguageServer.Protocol.Test
{
    [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute, System.Runtime.CompilerServices.CompilerGeneratedAttribute]
    public partial class CodeLensContainer : ContainerBase<CodeLens>
    {
        public CodeLensContainer(): this(Enumerable.Empty<CodeLens>())
        {
        }

        public CodeLensContainer(IEnumerable<CodeLens> items): base(items)
        {
        }

        public CodeLensContainer(params CodeLens[] items): base(items)
        {
        }

        [return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull(""items"")]
        public static CodeLensContainer? From(IEnumerable<CodeLens>? items) => items switch
        {
        not null => new CodeLensContainer(items), _ => null
        }

        ;
        [return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull(""items"")]
        public static implicit operator CodeLensContainer? (CodeLens[] items) => items switch
        {
        not null => new CodeLensContainer(items), _ => null
        }

        ;
        [return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull(""items"")]
        public static CodeLensContainer? From(params CodeLens[] items) => items switch
        {
        not null => new CodeLensContainer(items), _ => null
        }

        ;
        [return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull(""items"")]
        public static implicit operator CodeLensContainer? (Collection<CodeLens>? items) => items switch
        {
        not null => new CodeLensContainer(items), _ => null
        }

        ;
        [return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull(""items"")]
        public static CodeLensContainer? From(Collection<CodeLens>? items) => items switch
        {
        not null => new CodeLensContainer(items), _ => null
        }

        ;
        [return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull(""items"")]
        public static implicit operator CodeLensContainer? (List<CodeLens>? items) => items switch
        {
        not null => new CodeLensContainer(items), _ => null
        }

        ;
        [return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull(""items"")]
        public static CodeLensContainer? From(List<CodeLens>? items) => items switch
        {
        not null => new CodeLensContainer(items), _ => null
        }

        ;
        [return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull(""items"")]
        public static implicit operator CodeLensContainer? (in ImmutableArray<CodeLens>? items) => items switch
        {
        not null => new CodeLensContainer(items), _ => null
        }

        ;
        [return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull(""items"")]
        public static CodeLensContainer? From(in ImmutableArray<CodeLens>? items) => items switch
        {
        not null => new CodeLensContainer(items), _ => null
        }

        ;
        [return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull(""items"")]
        public static implicit operator CodeLensContainer? (ImmutableList<CodeLens>? items) => items switch
        {
        not null => new CodeLensContainer(items), _ => null
        }

        ;
        [return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull(""items"")]
        public static CodeLensContainer? From(ImmutableList<CodeLens>? items) => items switch
        {
        not null => new CodeLensContainer(items), _ => null
        }

        ;
    }
}
#nullable restore";
            await GenerationHelpers.AssertGeneratedAsExpected <StronglyTypedGenerator>(source, expected);
        }