Rubberduck.Inspections.ImplicitByRefParameterInspection.GetInspectionResults C# (CSharp) Method

GetInspectionResults() public method

public GetInspectionResults ( ) : IEnumerable
return IEnumerable
        public override IEnumerable<InspectionResultBase> GetInspectionResults()
        {
            var interfaceMembers = UserDeclarations.FindInterfaceImplementationMembers();

            var issues = (from item in UserDeclarations
                where
                    !item.IsInspectionDisabled(AnnotationName)
                    && item.DeclarationType == DeclarationType.Parameter
                    // ParamArray parameters do not allow an explicit "ByRef" parameter mechanism.               
                    && !((ParameterDeclaration)item).IsParamArray
                    && !interfaceMembers.Select(m => m.Scope).Contains(item.ParentScope)
                let arg = item.Context as VBAParser.ArgContext
                where arg != null && arg.BYREF() == null && arg.BYVAL() == null
                select new QualifiedContext<VBAParser.ArgContext>(item.QualifiedName, arg))
                .Select(issue => new ImplicitByRefParameterInspectionResult(this, issue.Context.ambiguousIdentifier().GetText(), issue));

 
            return issues;
        }
    }

Usage Example

        public void ImplicitByRefParameter_DoesNotReturnResult_ByRef()
        {
            const string inputCode =
@"Sub Foo(ByRef arg1 As Integer)
End Sub";

            //Arrange
            var builder = new MockVbeBuilder();
            VBComponent component;
            var vbe = builder.BuildFromSingleStandardModule(inputCode, out component);
            var mockHost = new Mock<IHostApplication>();
            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState());

            parser.Parse();
            if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); }

            var inspection = new ImplicitByRefParameterInspection(parser.State);
            var inspectionResults = inspection.GetInspectionResults();

            Assert.AreEqual(0, inspectionResults.Count());
        }
All Usage Examples Of Rubberduck.Inspections.ImplicitByRefParameterInspection::GetInspectionResults