Exemplo n.º 1
0
        private static void CollectAssignedStructParameters([NotNull][ItemNotNull] ICollection <IParameterSymbol> parameters,
                                                            [NotNull] IOperation bodyOperation, [NotNull] DiagnosticCollector collector)
        {
            var walker = new AssignmentWalker(parameters);

            walker.Visit(bodyOperation);

            foreach (IParameterSymbol parameter in walker.ParametersAssigned)
            {
                collector.Add(Diagnostic.Create(Rule, parameter.Locations[0], parameter.Name));
            }
        }
Exemplo n.º 2
0
        private static void AnalyzeOrdinaryParameters(BaseAnalysisContext <ICollection <IParameterSymbol> > context,
                                                      [NotNull] SyntaxNode bodySyntax, [NotNull] DiagnosticCollector collector)
        {
            DataFlowAnalysis dataFlowAnalysis = TryAnalyzeDataFlow(bodySyntax, context.Compilation);

            if (dataFlowAnalysis == null)
            {
                return;
            }

            foreach (IParameterSymbol parameter in context.Target)
            {
                if (dataFlowAnalysis.WrittenInside.Contains(parameter))
                {
                    collector.Add(Diagnostic.Create(Rule, parameter.Locations[0], parameter.Name));
                }
            }
        }