Example #1
0
        private static FlowAnalysisAnnotations DecodeFlowAnalysisAttributes(
            PEModule module,
            FieldDefinitionHandle handle
            )
        {
            FlowAnalysisAnnotations annotations = FlowAnalysisAnnotations.None;

            if (module.HasAttribute(handle, AttributeDescription.AllowNullAttribute))
            {
                annotations |= FlowAnalysisAnnotations.AllowNull;
            }
            if (module.HasAttribute(handle, AttributeDescription.DisallowNullAttribute))
            {
                annotations |= FlowAnalysisAnnotations.DisallowNull;
            }
            if (module.HasAttribute(handle, AttributeDescription.MaybeNullAttribute))
            {
                annotations |= FlowAnalysisAnnotations.MaybeNull;
            }
            if (module.HasAttribute(handle, AttributeDescription.NotNullAttribute))
            {
                annotations |= FlowAnalysisAnnotations.NotNull;
            }
            return(annotations);
        }
Example #2
0
        private static FlowAnalysisAnnotations DecodeFlowAnalysisAttributes(PEModule module, ParameterHandle handle)
        {
            FlowAnalysisAnnotations annotations = FlowAnalysisAnnotations.None;

            if (module.HasAttribute(handle, AttributeDescription.AllowNullAttribute))
            {
                annotations |= FlowAnalysisAnnotations.AllowNull;
            }
            if (module.HasAttribute(handle, AttributeDescription.DisallowNullAttribute))
            {
                annotations |= FlowAnalysisAnnotations.DisallowNull;
            }

            if (module.HasAttribute(handle, AttributeDescription.MaybeNullAttribute))
            {
                annotations |= FlowAnalysisAnnotations.MaybeNull;
            }
            else if (module.HasMaybeNullWhenOrNotNullWhenOrDoesNotReturnIfAttribute(handle, AttributeDescription.MaybeNullWhenAttribute, out bool when))
            {
                annotations |= (when ? FlowAnalysisAnnotations.MaybeNullWhenTrue : FlowAnalysisAnnotations.MaybeNullWhenFalse);
            }

            if (module.HasAttribute(handle, AttributeDescription.NotNullAttribute))
            {
                annotations |= FlowAnalysisAnnotations.NotNull;
            }
            else if (module.HasMaybeNullWhenOrNotNullWhenOrDoesNotReturnIfAttribute(handle, AttributeDescription.NotNullWhenAttribute, out bool when))
            {
                annotations |= (when ? FlowAnalysisAnnotations.NotNullWhenTrue : FlowAnalysisAnnotations.NotNullWhenFalse);
            }

            if (module.HasMaybeNullWhenOrNotNullWhenOrDoesNotReturnIfAttribute(handle, AttributeDescription.DoesNotReturnIfAttribute, out bool condition))
            {
                annotations |= (condition ? FlowAnalysisAnnotations.DoesNotReturnIfTrue : FlowAnalysisAnnotations.DoesNotReturnIfFalse);
            }

            return(annotations);
        }