Пример #1
0
        public static async Task <SessionWithSolution> CreateAsync(RemoteHostClient.Connection connection, Solution solution, CancellationToken cancellationToken)
        {
            Contract.ThrowIfNull(connection);
            Contract.ThrowIfNull(solution);

            PinnedRemotableDataScope scope = null;

            try
            {
                scope = await solution.GetPinnedScopeAsync(cancellationToken).ConfigureAwait(false);

                // set connection state for this session.
                // we might remove this in future. see https://github.com/dotnet/roslyn/issues/24836
                await connection.InvokeAsync(
                    WellKnownServiceHubServices.ServiceHubServiceBase_Initialize,
                    new object[] { scope.SolutionInfo },
                    cancellationToken).ConfigureAwait(false);

                return(new SessionWithSolution(connection, scope));
            }
            catch
            {
                // Make sure disposable objects are disposed when exceptions are thrown. The try/finally is used to
                // ensure 'scope' is disposed even if an exception is thrown while disposing 'connection'.
                try
                {
                    connection.Dispose();
                }
                finally
                {
                    scope?.Dispose();
                }

                // we only expect this to happen on cancellation. otherwise, rethrow
                cancellationToken.ThrowIfCancellationRequested();
                throw;
            }
        }
Пример #2
0
 private SessionWithSolution(RemoteHostClient.Connection connection, PinnedRemotableDataScope scope)
 {
     _connection = connection;
     _scope      = scope;
 }
Пример #3
0
        public static async Task <SessionWithSolution> CreateAsync(RemoteHostClient.Connection connection, PinnedRemotableDataScope scope, CancellationToken cancellationToken)
        {
            var sessionWithSolution = new SessionWithSolution(connection, scope);

            try
            {
                await connection.RegisterPinnedRemotableDataScopeAsync(scope).ConfigureAwait(false);

                return(sessionWithSolution);
            }
            catch
            {
                sessionWithSolution.Dispose();

                // we only expect this to happen on cancellation. otherwise, rethrow
                cancellationToken.ThrowIfCancellationRequested();
                throw;
            }
        }
Пример #4
0
 protected abstract Task OnRegisterPinnedRemotableDataScopeAsync(PinnedRemotableDataScope scope);
Пример #5
0
        public static async Task <SessionWithSolution> CreateAsync(RemoteHostClient.Connection connection, PinnedRemotableDataScope scope, CancellationToken cancellationToken)
        {
            var sessionWithSolution = new SessionWithSolution(connection, scope);

            try
            {
                // set connection state for this session.
                // we might remove this in future. see https://github.com/dotnet/roslyn/issues/24836
                await connection.InvokeAsync(
                    WellKnownServiceHubServices.ServiceHubServiceBase_Initialize,
                    new object[] { scope.SolutionInfo },
                    cancellationToken).ConfigureAwait(false);

                return(sessionWithSolution);
            }
            catch
            {
                sessionWithSolution.Dispose();

                // we only expect this to happen on cancellation. otherwise, rethrow
                cancellationToken.ThrowIfCancellationRequested();
                throw;
            }
        }
Пример #6
0
 protected override Task <Session> TryCreateServiceSessionAsync(
     string serviceName, PinnedRemotableDataScope snapshot, object callbackTarget, CancellationToken cancellationToken)
 {
     return(SpecializedTasks.Default <Session>());
 }
Пример #7
0
        protected virtual Task <Session> TryCreateServiceSessionAsync(string serviceName, PinnedRemotableDataScope snapshot, object callbackTarget, CancellationToken cancellationToken)
        {
#pragma warning disable CS0612 // leave it for now to not break backward compatibility
            return(CreateServiceSessionAsync(serviceName, snapshot, callbackTarget, cancellationToken));

#pragma warning restore CS0612 // Type or member is obsolete
        }
Пример #8
0
 private SessionWithSolution(KeepAliveSession keepAliveSession, PinnedRemotableDataScope scope)
 {
     KeepAliveSession = keepAliveSession;
     _scope           = scope;
 }
Пример #9
0
 private SessionWithSolution(RemoteServiceConnection connection, PinnedRemotableDataScope scope)
 {
     KeepAliveSession = connection;
     _scope           = scope;
 }
Пример #10
0
 protected abstract Task <Session> CreateServiceSessionAsync(string serviceName, PinnedRemotableDataScope snapshot, object callbackTarget, CancellationToken cancellationToken);
Пример #11
0
 public NoOpSession(PinnedRemotableDataScope scope, CancellationToken cancellationToken) :
     base(scope, cancellationToken)
 {
 }
Пример #12
0
 protected override Task <Session> CreateServiceSessionAsync(
     string serviceName, PinnedRemotableDataScope snapshot, object callbackTarget, CancellationToken cancellationToken)
 {
     return(Task.FromResult <Session>(new NoOpSession(snapshot, cancellationToken)));
 }
Пример #13
0
 private SessionWithSolution(RemoteHostClient.Connection connection, PinnedRemotableDataScope scope, CancellationToken cancellationToken)
 {
     _connection        = connection;
     _scope             = scope;
     _cancellationToken = cancellationToken;
 }
Пример #14
0
 public virtual Task RegisterPinnedRemotableDataScopeAsync(PinnedRemotableDataScope scope)
 {
     return(OnRegisterPinnedRemotableDataScopeAsync(scope));
 }