Ejemplo n.º 1
0
        private static TargetType GetNamedArgOrDefault <TargetType, Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly>(IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder, string name, Attribute attr)
        {
            var outcome = mdDecoder.NamedArgument(name, attr);

            if (outcome != null)
            {
                return((TargetType)outcome);
            }
            return(default(TargetType));
        }
Ejemplo n.º 2
0
        public virtual bool CheckOutcome <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly>(IOutput output, Method method, ProofOutcome outcome, string message, int primaryILOffset, int methodILOffset, IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder)
        {
            // at some places we get "this.x" instead of "x", both should be treated equal.
            message = message.Replace("this.", string.Empty);

            string canonical = CanonicalFormat(outcome, message, primaryILOffset, methodILOffset);

            this.actualOutcomes.Add(canonical);
            if (!this.expectedOutcomes.Contains(canonical))
            {
                // CCI1 hack (some offsets are off at method entries and exits) REMOVE ME ONCE WE MOVE OFF CCI1
                string canonical2 = CanonicalFormat(outcome, message, primaryILOffset, methodILOffset - 1);
                if (!this.expectedOutcomes.Contains(canonical2))
                {
                    errorCount++;
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
        public static MethodRegressionOutcomes GetOutcomes <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly>(Method method, IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder)
        {
            if (mdDecoder.GetMethodHashAttributeFlags(method).HasFlag(MethodHashAttributeFlags.IgnoreRegression))
            {
                return(new IgnoreRegressionOutcomes());
            }

            var outcomes = new Set <string>();

            foreach (Attribute attr in mdDecoder.GetAttributes(method))
            {
                var attrType = mdDecoder.AttributeType(attr);
                if (mdDecoder.Name(attrType) != "RegressionOutcomeAttribute")
                {
                    continue;
                }
                var posArgs = mdDecoder.PositionalArguments(attr);
                if (posArgs.Count == 0)
                {
                    var outcome = (ProofOutcome)(byte)GetNamedArgOrDefault <int, Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly>(mdDecoder, "Outcome", attr);

                    // at some places we have "this.x" instead of "x", both should be treated equal.
                    string msg           = ((string)mdDecoder.NamedArgument("Message", attr)).Replace("this.", string.Empty);
                    int    primaryOffset = GetNamedArgOrDefault <int, Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly>(mdDecoder, "PrimaryILOffset", attr);
                    int    methodOffset  = GetNamedArgOrDefault <int, Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly>(mdDecoder, "MethodILOffset", attr);

                    outcomes.Add(CanonicalFormat(outcome, msg, primaryOffset, methodOffset));
                }
                else
                {
                    outcomes.Add((string)posArgs[0]);
                }
            }
            return(new MethodRegressionOutcomes(outcomes));
        }
Ejemplo n.º 4
0
        public static int GetReanalyisCountIfAny <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly>(Method method, IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder)
        {
            if (mdDecoder.GetMethodHashAttributeFlags(method).HasFlag(MethodHashAttributeFlags.IgnoreRegression))
            {
                return(0);
            }

            foreach (Attribute attr in mdDecoder.GetAttributes(method))
            {
                Type attrType = mdDecoder.AttributeType(attr);
                if (mdDecoder.Name(attrType) != "RegressionReanalysisCountAttribute")
                {
                    continue;
                }
                var posArgs = mdDecoder.PositionalArguments(attr);
                if (posArgs.Count != 0)
                {
                    return((int)posArgs[0]);
                }
            }

            return(0);
        }
Ejemplo n.º 5
0
 public RegressionOutput(IOutputFullResults <Method, Assembly> output, GeneralOptions options, IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder)
     : base(output)
 {
     this.options             = options;
     this.mdDecoder           = mdDecoder;
     this.methodAnalysisCount = new Dictionary <Method, int>();
 }
Ejemplo n.º 6
0
        internal bool CheckOutcome <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly>(IOutput output, Assembly assembly, System.CodeDom.Compiler.CompilerError error, IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder)
        {
            string canonical = error.ErrorText;

            this.actualOutcomes.Add(canonical);
            if (!this.expectedOutcomes.Contains(canonical))
            {
                errorCount++;
                return(false);
            }
            return(true);
        }
Ejemplo n.º 7
0
        public static AssemblyRegressionOutcomes GetOutcomes <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly>(Assembly assembly, IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder)
        {
            Set <string> outcomes = new Set <string>();

            foreach (Attribute attr in mdDecoder.GetAttributes(assembly))
            {
                Type attrType = mdDecoder.AttributeType(attr);
                if (mdDecoder.Name(attrType) != "RegressionOutcomeAttribute")
                {
                    continue;
                }
                string expectedString = (string)mdDecoder.PositionalArguments(attr)[0];
                outcomes.Add(expectedString);
            }
            return(new AssemblyRegressionOutcomes(outcomes));
        }
Ejemplo n.º 8
0
 internal override bool CheckOutcome <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly>(IOutput output, Method method, System.CodeDom.Compiler.CompilerError error, IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder)
 {
     return(true);
 }
Ejemplo n.º 9
0
 public override bool CheckOutcome <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly>(IOutput output, Method method, ProofOutcome outcome, string message, int primaryILOffset, int methodILOffset, IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder)
 {
     return(true);
 }