コード例 #1
0
        public async Task GetMiddlewareNamespaces_Does_Not_Return_Duplicates()
        {
            _lcManager.RegisterMiddlewareClass(WebFormsAppLifecycleEvent.BeginRequest, TestMiddlewareName1, TestMiddlewareNamespace, TestOriginClassName, false);
            _lcManager.RegisterMiddlewareClass(WebFormsAppLifecycleEvent.EndRequest, TestMiddlewareName2, TestMiddlewareNamespace, TestOriginClassName, false);

            var results = await _lcManager.GetMiddlewareNamespaces(_token);

            Assert.DoesNotThrow(() => results.Single(result => result.Equals(TestMiddlewareNamespace)));
        }
コード例 #2
0
        private async Task <IEnumerable <UsingDirectiveSyntax> > GetAllUsingStatements()
        {
            // NOTE: Removed temporarily until usings can be better determined, at the moment, too
            // many are being removed
            //var typeRequiredNamespaceNames = _sourceFileSemanticModel
            //    .GetNamespacesReferencedByType(_originalDeclarationSyntax)
            //    .Select(namespaceSymbol => namespaceSymbol.ToDisplayString());

            var typeRequiredNamespaceNames = _sourceFileSemanticModel.GetOriginalUsingNamespaces();

            typeRequiredNamespaceNames = CodeSyntaxHelper.RemoveFrameworkUsings(typeRequiredNamespaceNames);

            // Merging required using statements for middleware and source type contents
            try
            {
                var middlewareNamespaceNames = await _taskManager.ManagedRun(_taskId, (token) => _lifecycleManager.GetMiddlewareNamespaces(token));

                return(CodeSyntaxHelper.BuildUsingStatements(typeRequiredNamespaceNames.Union(middlewareNamespaceNames).Union(StartupSyntaxHelper.RequiredNamespaces)));
            }
            catch (OperationCanceledException e)
            {
                LogHelper.LogError(e, string.Format(
                                       Constants.CaneledServiceCallLogTemplate,
                                       Rules.Config.Constants.WebFormsErrorTag,
                                       GetType().Name,
                                       typeof(LifecycleManagerService).Name,
                                       GetMiddlewareNamespacesLogCall));

                return(CodeSyntaxHelper.BuildUsingStatements(typeRequiredNamespaceNames)
                       .AddComment(string.Format(Constants.OperationFailedCommentTemplate, AddMiddlewareUsingsOperation)));
            }
        }