public override object VisitCompilation_unit([NotNull] CSharpParser.Compilation_unitContext context) { _isFoundConfigureServices = false; var usingNamespaceList = new List <string>(); foreach (var regInfo in _startupRegInfoList) { usingNamespaceList.Add(regInfo.ServiceNamespace); } var missingUsingDirectives = _cSharpParserService.GetUsingDirectivesNotInContext( context, usingNamespaceList); if (missingUsingDirectives.Count > 0) { var usingStopIndex = _cSharpParserService.GetUsingStopIndex(context); var usingDirectiveStr = _cSharpParserService.GenerateUsingDirectives( missingUsingDirectives.ToList(), usingStopIndex.Equals(context.Start)); IsModified = true; Rewriter.InsertAfter(usingStopIndex, usingDirectiveStr); } VisitChildren(context); return(null); }
public override object VisitCompilation_unit([NotNull] CSharpParser.Compilation_unitContext context) { var missingUsingDirectives = _cSharpParserService.GetUsingDirectivesNotInContext( context, new List <string>() { _serviceNamespace }); if (missingUsingDirectives.Count > 0) { var usingStopIndex = _cSharpParserService.GetUsingStopIndex(context); var usingDirectiveStr = _cSharpParserService.GenerateUsingDirectives( missingUsingDirectives.ToList(), usingStopIndex.Equals(context.Start)); _isRewritten = true; Rewriter.InsertAfter(usingStopIndex, usingDirectiveStr); } VisitChildren(context); IsModified = _isRewritten && _isConstructorClassFound; if (!_isConstructorClassFound) { _logger.LogWarning($"No class found called {_constructorClassName} in namespace " + $"{_constructorClassNamespace}. Failed to inject {_serviceInterfaceType} into class."); } return(null); }
public override object VisitCompilation_unit([NotNull] CSharpParser.Compilation_unitContext context) { VisitChildren(context); if (IsModified) { var missingUsingDirectives = _cSharpParserService.GetUsingDirectivesNotInContext( context, new List <string>() { _breadcrumbServiceNamespace }); if (missingUsingDirectives.Count > 0) { var usingStopIndex = _cSharpParserService.GetUsingStopIndex(context); var usingDirectiveStr = _cSharpParserService.GenerateUsingDirectives( missingUsingDirectives.ToList(), usingStopIndex.Equals(context.Start)); Rewriter.InsertAfter(usingStopIndex, usingDirectiveStr); } } return(null); }