예제 #1
0
        protected override void Run(
            IInvocationExpression element,
            ElementProblemAnalyzerData data,
            IHighlightingConsumer consumer)
        {
            var templateArgument = element.GetTemplateArgument();
            var templateText     = templateArgument?.TryGetTemplateText();

            if (templateText == null)
            {
                return;
            }

            var messageTemplate = _messageTemplateParser.Parse(templateText);

            if (messageTemplate.PositionalProperties == null)
            {
                return;
            }

            foreach (var property in messageTemplate.PositionalProperties)
            {
                consumer.AddHighlighting(new PositionalPropertyUsedWarning(templateArgument.GetTokenInformation(property)));
            }
        }
        protected override void Run(
            IInvocationExpression element,
            ElementProblemAnalyzerData data,
            IHighlightingConsumer consumer)
        {
            var templateArgument = element.GetTemplateArgument();

            if (templateArgument == null)
            {
                return;
            }

            var stringLiteral = StringLiteralAltererUtil.TryCreateStringLiteralByExpression(templateArgument.Value);

            if (stringLiteral == null)
            {
                return;
            }

            var messageTemplate = _messageTemplateParser.Parse(stringLiteral.Expression.GetUnquotedText());

            if (messageTemplate.PositionalProperties == null)
            {
                return;
            }

            foreach (var property in messageTemplate.PositionalProperties)
            {
                consumer.AddHighlighting(new PositionalPropertyUsedWarning(stringLiteral, property, stringLiteral.GetTokenDocumentRange(property)));
            }
        }
        protected override void Run(IFieldDeclaration element, ElementProblemAnalyzerData data,
                                    IHighlightingConsumer consumer)
        {
            var propertyNameAttribute =
                element.DeclaredElement
                .With(x =>
                      x.GetAttributeInstances(
                          new ClrTypeName(typeof(ContractPublicPropertyNameAttribute).FullName), false)
                      .FirstOrDefault());

            if (propertyNameAttribute == null)
            {
                return;
            }

            var fieldOrPropertyName = (string)propertyNameAttribute.PositionParameter(0).ConstantValue.Value;
            var type = element.GetContainingTypeDeclaration();

            var fieldOrProperty =
                type.MemberDeclarations
                .FirstOrDefault(md => md.NameIdentifier.With(x => x.Name) == fieldOrPropertyName &&
                                (md is IFieldDeclaration || md is IPropertyDeclaration));

            if (fieldOrProperty == null || fieldOrProperty.GetAccessRights() != AccessRights.PUBLIC)
            {
                consumer.AddHighlighting(
                    new ContractPublicPropertyNameHighlighing(element, fieldOrPropertyName, fieldOrProperty),
                    element.GetDocumentRange(), element.GetContainingFile());
            }
        }
        protected override void Run(
            IInvocationExpression element,
            ElementProblemAnalyzerData data,
            IHighlightingConsumer consumer)
        {
            var templateArgument = element.GetTemplateArgument();
            var templateText     = templateArgument?.TryGetTemplateText();

            if (templateText == null)
            {
                return;
            }

            var messageTemplate = _messageTemplateParser.Parse(templateText);

            if (messageTemplate.NamedProperties == null)
            {
                return;
            }

            foreach (var duplicates in messageTemplate.NamedProperties
                     .GroupBy(n => n.PropertyName)
                     .Where(g => g.Count() > 1))
            {
                foreach (var token in duplicates)
                {
                    consumer.AddHighlighting(new DuplicateTemplatePropertyWarning(templateArgument.GetTokenInformation(token)));
                }
            }
        }
예제 #5
0
        protected override void Run(
            IT4Directive element,
            ElementProblemAnalyzerData data,
            IHighlightingConsumer consumer
            )
        {
            var nameToken = element.Name;

            if (nameToken == null)
            {
                return;
            }
            var directiveInfo = T4DirectiveInfoManager.GetDirectiveByName(nameToken.GetText());
            var missingInfos  = directiveInfo?.SupportedAttributes
                                .Where(requiredAttributeInfo =>
                                       requiredAttributeInfo.IsRequired &&
                                       !element
                                       .AttributesEnumerable
                                       .Select(attribute => attribute.Name)
                                       .Any(name => name
                                            .GetText()
                                            .Equals(requiredAttributeInfo.Name, StringComparison.OrdinalIgnoreCase)
                                            )
                                       )
                                .AsList();

            if (missingInfos?.Any() != true)
            {
                return;
            }
            consumer.AddHighlighting(new MissingRequiredAttributeError(nameToken, CreateMessage(missingInfos)));
        }
예제 #6
0
        protected override void Run(IInvocationExpression invocationExpression, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
        {
            if (!invocationExpression.IsUnderAsyncDeclaration())
            {
                return;
            }

            var referenceCurrentResolveResult = invocationExpression.Reference?.Resolve();

            if (referenceCurrentResolveResult?.IsValid() != true)
            {
                return;
            }

            var invocationMethod = referenceCurrentResolveResult.DeclaredElement as IMethod;

            if (invocationMethod == null)
            {
                return;
            }

            var invokedType = (invocationExpression.ConditionalQualifier as IReferenceExpression)?.QualifierExpression?.Type();

            var findingReslt = asyncMethodFinder.FindEquivalentAsyncMethod(invocationMethod, invokedType);

            if (findingReslt.Method == null || !findingReslt.ParameterCompareResult.CanBeConvertedToAsync())
            {
                return;
            }

            consumer.AddHighlighting(new CanBeUseAsyncMethodHighlighting(invocationExpression));
        }
        protected override void Analyze(IConditionalAccessExpression expression, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
        {
            if (!expression.HasConditionalAccessSign)
            {
                return;
            }
            if (!(expression.ConditionalQualifier is IReferenceExpression qualifier))
            {
                return;
            }
            var resolve = qualifier.Reference.Resolve();

            if (resolve.ResolveErrorType != ResolveErrorType.OK)
            {
                return;
            }
            var unityObjectType = TypeFactory.CreateTypeByCLRName(KnownTypes.Object, expression.GetPsiModule());

            if (!qualifier.Type().IsSubtypeOf(unityObjectType))
            {
                return;
            }

            consumer.AddHighlighting(new UnityObjectNullPropagationWarning(expression));
        }
예제 #8
0
        protected override void Run(
            IClassDeclaration element,
            ElementProblemAnalyzerData data,
            IHighlightingConsumer consumer)
        {
            if (!element.IsFromAspNetCoreMvcProject() ||
                !element.IsFromFluentValidationProject() ||
                !element.DeclaredElement.IsFluentValidationAbstractValidator())
            {
                return;
            }

            foreach (var constructorDeclaration in element.ConstructorDeclarations)
            {
                foreach (var invocationExpression in constructorDeclaration.Descendants <IInvocationExpression>())
                {
                    var referenceExpression = invocationExpression.InvokedExpression as IReferenceExpression;
                    var nameIdentifier      = referenceExpression?.NameIdentifier;
                    var nameIdentifierName  = nameIdentifier?.Name;
                    if (_asyncMethods.Contains(nameIdentifierName))
                    {
                        consumer.AddHighlighting(
                            new AsyncValidationHighlighting(referenceExpression, nameIdentifierName));
                    }
                }
            }
        }
예제 #9
0
            public ShaderLabErrorStageProcess(IDaemonProcess process, DaemonProcessKind processKind, ElementProblemAnalyzerRegistrar elementProblemAnalyzerRegistrar, IContextBoundSettingsStore settings, IShaderLabFile file)
                : base(process, settings, file)
            {
                var elementProblemAnalyzerData = new ElementProblemAnalyzerData(process, processKind, settings);

                myElementAnalyzerDispatcher = elementProblemAnalyzerRegistrar.CreateDispatcher(elementProblemAnalyzerData);
            }
 protected override void Run(IClassDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
 {
     if (element.DeclaredName.Contains("Foo"))
     {
         consumer.AddHighlighting(new ClassNameWarning(element, element.NameIdentifier.GetDocumentRange()));
     }
 }
예제 #11
0
        protected override void Run(IDeclaration declaration, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
        {
            var processKind = data.GetDaemonProcessKind();

            if (processKind == DaemonProcessKind.VISIBLE_DOCUMENT && IsTypeHighlightingEnabled(data.SettingsStore))
                RunForVisibleDocument(declaration, consumer);
        }
예제 #12
0
 // Implements ElementProblemAnalyzer instead of the Daemon because of issues with multi line commenting.
 protected override void Run(ICSharpLiteralExpression element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
 {
     if (ElementLocalized(element))
     {
         consumer.AddHighlighting(new LocalizeStringSuggestion(element), element.GetDocumentRange(), element.GetContainingFile());
     }
 }
 public virtual void PublicRun(
     IDeclaration declaration,
     IDeclaredElement declaredElement,
     ElementProblemAnalyzerData data,
     IHighlightingConsumer consumer)
 {
 }
예제 #14
0
        protected override void Run(ICSharpCommentNode element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
        {
            if (element.GetContainingFunctionLikeDeclarationOrClosure() == null)
            {
                return;
            }

            var leadingWhitespaceCharacterCount = GetLeadingWhitespaceCharacterCount(element.CommentText);

            var commentText = element.CommentText.Remove(0, leadingWhitespaceCharacterCount);

            if (commentText.StartsWith("ReSharper disable once", StringComparison.Ordinal))
            {
                consumer.AddHighlighting(
                    new LocalSuppressionHighlighting("Avoid local suppression.", element, leadingWhitespaceCharacterCount, true));
            }
            else
            {
                if (commentText.StartsWith("ReSharper disable", StringComparison.Ordinal))
                {
                    consumer.AddHighlighting(
                        new LocalSuppressionHighlighting("Avoid local suppression.", element, leadingWhitespaceCharacterCount, false));
                }
            }
        }
예제 #15
0
        protected override void Run(ITreeNode element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
        {
            IFunction   thisElement = null;
            ILocalScope topScope    = null;
            var         function    = element as ICSharpFunctionDeclaration;

            if (function != null)
            {
                thisElement = function.DeclaredElement;
                topScope    = function.Body as ILocalScope;
            }

            var inspector = new ClosureInspector(element, thisElement);

            element.ProcessDescendants(inspector);

            // report closures allocations
            if (inspector.Closures.Count > 0)
            {
                ReportClosureAllocations(
                    element, thisElement, topScope, inspector, consumer);
            }

            // report non-cached generic lambda expressions
            if (function != null && inspector.ClosurelessLambdas.Count > 0)
            {
                ReportClosurelessAllocations(function, inspector, consumer);
            }

            // report anonymous types in query expressions
            if (inspector.AnonymousTypes.Count > 0)
            {
                ReportAnonymousTypes(inspector, consumer);
            }
        }
예제 #16
0
        private IHighlighting GetHighlighting(IMethodDeclaration element, ElementProblemAnalyzerData data)
        {
            var maxStatements = data.SettingsStore.GetValue((CleanCodeSettings s) => s.MaximumMethodStatements);
            var maxDeclarations = data.SettingsStore.GetValue((CleanCodeSettings s) => s.MaximumDeclarationsInMethod);

            return CheckStatementCount(element, maxStatements) ?? CheckDeclarationCount(element, maxDeclarations);
        }
예제 #17
0
        protected override void Analyze(IMultiplicativeExpression expression, ElementProblemAnalyzerData data,
                                        IHighlightingConsumer consumer)
        {
            var byLeft = MultiplicativeExpressionNavigator.GetByLeftOperand(expression.GetContainingParenthesizedExpression());

            if (byLeft != null)
            {
                return;
            }

            var byRight = MultiplicativeExpressionNavigator.GetByRightOperand(expression.GetContainingParenthesizedExpression());

            if (byRight != null)
            {
                return;
            }


            var(count, hasUnknownType) = CalculateMatrixIntMulCount(expression);
            if (hasUnknownType)
            {
                return;
            }

            if (count > GetElementCount(expression.GetExpressionType()))
            {
                consumer.AddHighlighting(new InefficientMultiplicationOrderWarning(expression));
            }
        }
예제 #18
0
        protected override void Analyze(IInvocationExpression element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
        {
            if (!myAssetSerializationMode.IsForceText)
            {
                return;
            }

            if (!myUnityYamlSupport.IsParsingEnabled.Value)
            {
                return;
            }

            if (IsLayerMaskGetMask(element) || IsLayerMaskNameToLayer(element))
            {
                foreach (var argument in element.ArgumentList.Arguments)
                {
                    if (argument == null)
                    {
                        return;
                    }

                    var literal = (argument.Value as ICSharpLiteralExpression)?.ConstantValue.Value as string;
                    if (literal == null)
                    {
                        return;
                    }

                    var cache = element.GetSolution().TryGetComponent <UnityProjectSettingsCache>();
                    if (cache != null && !cache.HasLayer(literal))
                    {
                        consumer.AddHighlighting(new UnknownLayerWarning(argument));
                    }
                }
            }
        }
        protected override void Run(ICSharpTreeNode element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
        {
            ICSharpExpression exception;

            switch (element)
            {
            case IThrowStatement throwStatement:
                exception = throwStatement.Exception;
                break;

            case IThrowExpression throwExpression:
                exception = throwExpression.Exception;
                break;

            default: return;
            }

            if (exception == null)
            {
                return;
            }

            if (unthrowableExceptions.TryGetValue(exception.GetExpressionType().ToString(), out var reason))
            {
                Debug.Assert(reason != null);

                consumer.AddHighlighting(new UnthrowableExceptionWarning(reason, exception));
            }
        }
예제 #20
0
        protected override void Run(IUserDeclaredTypeUsage typeUsage, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
        {
            var iRequire = typeUsage.TypeName.Reference.Resolve().DeclaredElement as IInterface;

            if (iRequire == null)
            {
                return;
            }

            if (!ZoneConstants.IsIRequire(iRequire))
            {
                return;
            }

            foreach (var typeArgument in typeUsage.TypeName.TypeArguments)
            {
                var declaredType = typeArgument as IDeclaredType;
                if (declaredType != null)
                {
                    var typeElement = declaredType.GetTypeElement();
                    if (typeElement != null)
                    {
                        if (!ZoneConstants.IsZoneDefinitionClass(typeElement))
                        {
                            consumer.AddHighlighting(new UndefinedAxisError(typeUsage, typeElement.GetClrName().FullName,
                                                                            ZoneConstants.ZoneDefinitionAttributeNameFull), typeUsage.GetContainingFile());
                        }
                    }
                }
            }
        }
예제 #21
0
        protected override void Run(T element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
        {
            var processKind = data.GetDaemonProcessKind();

            if (processKind != DaemonProcessKind.VISIBLE_DOCUMENT && processKind != DaemonProcessKind.SOLUTION_ANALYSIS)
            {
                return;
            }

            if (data.SourceFile == null)
            {
                return;
            }

            if (!element.Language.Is <JsonNewLanguage>())
            {
                return;
            }

            if (!data.SourceFile.IsAsmDef())
            {
                return;
            }

            Analyze(element, data, consumer);
        }
예제 #22
0
        protected override void Analyze(IInvocationExpression element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
        {
            if (!myAssetSerializationMode.IsForceText)
            {
                return;
            }

            if (!myUnityYamlSupport.IsParsingEnabled.Value)
            {
                return;
            }

            if (element.IsInputAxisMethod() || element.IsInputButtonMethod())
            {
                var argument = element.ArgumentList.Arguments.FirstOrDefault();
                var literal  = (argument?.Value as ICSharpLiteralExpression)?.ConstantValue.Value as string;
                if (literal == null)
                {
                    return;
                }

                var cache = element.GetSolution().TryGetComponent <UnityProjectSettingsCache>();
                if (cache != null && !cache.HasInput(literal))
                {
                    consumer.AddHighlighting(new UnknownInputAxesWarning(argument));
                }
            }
        }
예제 #23
0
        protected override void Run(
            ICSharpExpression expression, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
        {
            switch (expression)
            {
            case IInvocationExpression invocationExpression:
                CheckInheritedVirtualMethodInvocationOverValueType(invocationExpression, consumer);
                break;

            case IReferenceExpression referenceExpression:
                CheckStructMethodConversionToDelegateInstance(referenceExpression, consumer);
                break;

            case ICastExpression castExpression:
                CheckExpressionExplicitConversion(castExpression, data.GetTypeConversionRule(), consumer);
                break;

            case IParenthesizedExpression _:
            case ICheckedExpression _:
            case IUncheckedExpression _:
            case ISuppressNullableWarningExpression _:
                return; // do not analyze
            }

            CheckExpressionImplicitConversion(expression, expression.GetTypeConversionRule(), consumer);
        }
        protected override void Analyze(IAttribute element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
        {
            if (!(element.TypeReference?.Resolve().DeclaredElement is ITypeElement attributeTypeElement))
            {
                return;
            }

            // Otherwise we'll treat it as targeting a method
            if (element.Target == AttributeTarget.Return)
            {
                return;
            }

            if (ourAttributeLookups.TryGetValue(attributeTypeElement.GetClrName(), out var func))
            {
                var methodDeclaration = MethodDeclarationNavigator.GetByAttribute(element);
                if (methodDeclaration == null)
                {
                    return;
                }

                var predefinedType  = myPredefinedTypeCache.GetOrCreatePredefinedType(element.GetPsiModule());
                var methodSignature = func(predefinedType);

                var match = methodSignature.Match(methodDeclaration);
                AddMethodSignatureInspections(consumer, methodDeclaration, methodSignature, match);
            }
        }
예제 #25
0
 protected override void Run(IInvocationExpression element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
 {
     if (syncWaitChecker.CanReplaceWaitToAsync(element))
     {
         consumer.AddHighlighting(new AsyncWaitHighlighting(element));
     }
 }
        protected override void Analyze(IAttribute element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
        {
            var arguments = element.Arguments;
            var argument  = UnityShortcutCache.GetArgument(0, "itemName", arguments);
            var name      = argument?.Value?.ConstantValue.Value as string;

            if (name == null)
            {
                return;
            }

            var shortcut = UnityShortcutCache.ExtractShortcutFromName(name);

            if (shortcut == null)
            {
                return;
            }

            if (myCache.GetCount(shortcut) > 1)
            {
                var files       = myCache.GetSourceFileWithShortCut(shortcut);
                var sourceFile  = element.GetSourceFile();
                var anotherFile = files.FirstOrDefault(t => t != sourceFile);
                if (anotherFile == null)
                {
                    consumer.AddHighlighting(new DuplicateShortcutWarning(argument, "this file"));
                }
                else
                {
                    consumer.AddHighlighting(new DuplicateShortcutWarning(argument, anotherFile.Name));
                }
            }
        }
예제 #27
0
        protected override void Run(T element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
        {
            if (!myIsEnabled.Value)
            {
                return;
            }

            var ownerNamespace = element.GetContainingNamespaceDeclaration();

            if (ownerNamespace != null)
            {
                var ownerNs         = ownerNamespace.DeclaredElement;
                var declaredElement = Resolve(element);
                if (declaredElement != null)
                {
                    var referencedNs      = declaredElement.GetContainingNamespace();
                    var ownerMark         = myMarks.GetMark(ownerNs);
                    var referencedMark    = myMarks.GetMark(referencedNs);
                    var notSpecifiedClass = myMarks.EnumerateClasses(referencedMark.Substract(ownerMark)).FirstOrDefault();
                    if (notSpecifiedClass != null)
                    {
                        consumer.AddHighlighting(new IncorrectReferenceError(element, notSpecifiedClass, string.Format("Dependency on {0} is not satisfied in the containing namespace", notSpecifiedClass.ShortName)), element.GetContainingNode <IFile>());
                    }
                }
            }
        }
예제 #28
0
        protected override void Analyze(IInvocationExpression expression, ElementProblemAnalyzerData data,
                                        IHighlightingConsumer consumer)
        {
            if (!(expression.InvokedExpression is IReferenceExpression referenceExpression))
            {
                return;
            }

            var reference = expression.Reference;

            if (reference == null)
            {
                return;
            }

            var info = reference.Resolve();

            if (info.ResolveErrorType == ResolveErrorType.OK && info.DeclaredElement is IMethod allocMethod)
            {
                var nonAllocMethod = GetNonAllocVersion(allocMethod, expression);
                if (nonAllocMethod != null)
                {
                    consumer.AddHighlighting(new PreferNonAllocApiWarning(expression, referenceExpression, nonAllocMethod));
                }
            }
        }
예제 #29
0
        protected override void Analyze(IEqualityExpression element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
        {
            if (element.LeftOperand == null || element.RightOperand == null)
            {
                return;
            }

            var predefinedType = element.GetPredefinedType();

            if (!Equals(element.LeftOperand.Type(), predefinedType.String) ||
                !Equals(element.RightOperand.Type(), predefinedType.String))
            {
                return;
            }

            var leftOperand  = element.LeftOperand as IReferenceExpression;
            var rightOperand = element.RightOperand as IReferenceExpression;

            if (leftOperand == null && rightOperand == null)
            {
                return;
            }

            var isLeftOperandTagReference  = IsTagReference(leftOperand);
            var isRightOperandTagReference = IsTagReference(rightOperand);

            if (isLeftOperandTagReference || isRightOperandTagReference)
            {
                consumer.AddHighlighting(new ExplicitTagStringComparisonWarning(element, isLeftOperandTagReference));
            }
        }
        protected override void Run(
            IInvocationExpression element,
            ElementProblemAnalyzerData data,
            IHighlightingConsumer consumer)
        {
            var referenceExpression = element.InvokedExpression as IReferenceExpression;
            var nameIdentifier      = referenceExpression?.NameIdentifier;

            if (nameIdentifier == null || nameIdentifier.Name != nameof(AbstractValidator <object> .Validate))
            {
                return;
            }

            if (!element.IsFromFluentValidationProject())
            {
                return;
            }

            var containingType = referenceExpression.QualifierExpression?.Type().GetTypeElement();

            if (containingType == null)
            {
                return;
            }

            foreach (var constructor in containingType.Constructors)
            {
                if (HasAsyncInvocations(constructor))
                {
                    consumer.AddHighlighting(
                        new NonAsyncValidationHighlighting(referenceExpression, nameIdentifier.Name));
                }
            }
        }
        protected override void Run(IDllImportMethodDeclaration importMethod, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
        {
            var element = importMethod.MethodDeclaration;
            var libraryName = importMethod.ImportedDll;
            var factory = new LibraryFactory();
            var library = factory.LoadLibrary(libraryName);
            var export = library[element.NameIdentifier.Name];
            if (export == null || export.Parameters.Count != element.ParameterDeclarations.Count)
            {
                return;
            }

            for (var i = 0; i < element.ParameterDeclarations.Count; i++ )
            {
                var parameter = element.ParameterDeclarations[i];
                var knownParameter = export.Parameters[i];
                var exportedType = new ClrTypeName(knownParameter.CLRType.FullName);
                if (parameter.Type.IsInt() && exportedType.Equals(IntPtrClrType))
                {
                    consumer.AddHighlighting(new DllImportInt32ForIntPtrHighlighting(parameter));
                }
                var marshalAs = parameter.Attributes.GetAttibuteOfCLRType(MarshalAsAttribute);
                if (knownParameter.UnmanagedType.HasValue && marshalAs != null && marshalAs.ConstructorArgumentExpressions.Count == 1)
                {
                    var argumentExpression = marshalAs.ConstructorArgumentExpressions[0];
                    if (!argumentExpression.IsConstantValue())
                    {
                        continue;
                    }
                    var shortType = argumentExpression.ConstantValue.IsShort();
                    UnmanagedType unmanagedType;
                    if (shortType)
                    {
                        unmanagedType = (UnmanagedType)(short)argumentExpression.ConstantValue.Value;
                    }
                    else
                    {
                        unmanagedType = (UnmanagedType)argumentExpression.ConstantValue.Value;
                    }
                    if (knownParameter.UnmanagedType.Value != unmanagedType)
                    {
                        consumer.AddHighlighting(new DllImportIncorrectParameterMarshalHighlighting(parameter, argumentExpression, knownParameter.UnmanagedType.Value));
                    }
                }
            }
        }