private Result CreateBaselinedResult(BaselineState newBaselineState)
        {
            // Clone the most recent copy of the Result
            Result result = (CurrentResult ?? PreviousResult).Result.DeepClone();

            // Assign a Guid, if not assigned by the Result producer
            result.Guid = result.Guid ?? Guid.NewGuid().ToString(SarifConstants.GuidFormat);

            // Assign a CorrelationGuid to map copies of this logical Result across baselined logs to each other
            if (PreviousResult?.Result == null)
            {
                // If this Result is new, use the Guid as the Correlation Guid for this 'series'
                result.CorrelationGuid = result.CorrelationGuid ?? result.Guid;
            }
            else
            {
                // If not, persist forward the CorrelationGuid already assigned
                //  or the Guid if the previous log was never baselined
                //  or the new Guid if the previous Result never had a Guid assigned at all
                result.CorrelationGuid = PreviousResult.Result.CorrelationGuid ?? PreviousResult.Result.Guid ?? result.Guid;
            }

            result.BaselineState = newBaselineState;

            return(result);
        }
Esempio n. 2
0
        public override int GetHashCode()
        {
            int result = 17;

            unchecked
            {
                if (RuleId != default(string))
                {
                    result = (result * 31) + RuleId.GetHashCode();
                }

                if (Rule != default(Rule))
                {
                    result = (result * 31) + Rule.GetHashCode();
                }

                if (Guid != default(string))
                {
                    result = (result * 31) + Guid.GetHashCode();
                }

                if (IsActive != default(bool))
                {
                    result = (result * 31) + IsActive.GetHashCode();
                }

                if (Message != default(string))
                {
                    result = (result * 31) + Message.GetHashCode();
                }

                if (StartLine != default(int))
                {
                    result = (result * 31) + StartLine.GetHashCode();
                }

                if (WhenDetectedUtc != default(DateTime))
                {
                    result = (result * 31) + WhenDetectedUtc.GetHashCode();
                }

                if (BaselineState != default(BaselineState))
                {
                    result = (result * 31) + BaselineState.GetHashCode();
                }

                if (Properties != default(IDictionary <String, String>))
                {
                    result = (result * 31) + Properties.GetHashCode();
                }

                if (Tags != default(IList <int>))
                {
                    result = (result * 31) + Tags.GetHashCode();
                }
            }

            return(result);
        }
Esempio n. 3
0
        public static BaselineStateVersionOne CreateBaselineStateVersionOne(BaselineState v2BaselineState)
        {
            switch (v2BaselineState)
            {
            case BaselineState.Absent:
                return(BaselineStateVersionOne.Absent);

            case BaselineState.Existing:
                return(BaselineStateVersionOne.Existing);

            case BaselineState.New:
                return(BaselineStateVersionOne.New);

            default:
                return(BaselineStateVersionOne.None);
            }
        }
Esempio n. 4
0
        public void MatchedResults_SetsFirstDetectionTime()
        {
            var sb = new StringBuilder();

            foreach (FirstDetectionTimeTestCase testCase in firstDetectionTimeTestCases)
            {
                DateTime expectedFirstDetectionTime = testCase.ExpectedFirstDetectionTime.HasValue
                    ? testCase.ExpectedFirstDetectionTime.Value
                    : fakeNow;

                ExtractedResult previousExtracted = testCase.PreviousResult != null
                    ? new ExtractedResult(testCase.PreviousResult, testCase.PreviousRun)
                    : null;
                ExtractedResult currentExtracted = testCase.CurrentResult != null
                    ? new ExtractedResult(testCase.CurrentResult, testCase.CurrentRun)
                    : null;
                MatchedResults matchedResults = new MatchedResults(previousExtracted, currentExtracted);

                Result result = matchedResults.CalculateBasedlinedResult(DictionaryMergeBehavior.InitializeFromMostRecent /* arbitrary */);

                BaselineState actualBaselineState      = result.BaselineState;
                DateTime?     actualFirstDetectionTime = result?.Provenance?.FirstDetectionTimeUtc;
                if (actualFirstDetectionTime.HasValue && actualFirstDetectionTime.Value >= fakeNow)
                {
                    actualFirstDetectionTime = fakeNow;
                }

                if (actualBaselineState != testCase.ExpectedBaselineState ||
                    actualFirstDetectionTime != expectedFirstDetectionTime)
                {
                    sb.AppendLine($"    Test: {testCase.Name}");
                    sb.AppendLine($"        Expected: {testCase.ExpectedBaselineState}\t{testCase.ExpectedFirstDetectionTime}");
                    sb.AppendLine($"        Actual:   {actualBaselineState}\t{actualFirstDetectionTime}");
                }
            }

            sb.Length.Should().Be(0,
                                  $"all test cases should pass, but the following test cases failed:\n{sb}");
        }
        private static string ChangedSymbol(BaselineState state)
        {
            switch (state)
            {
            case BaselineState.Unchanged:
                return("=");

            case BaselineState.New:
                return("+");

            case BaselineState.Absent:
                return("-");

            case BaselineState.Updated:
                return("~");

            case BaselineState.None:
                return(" ");

            default:
                throw new NotImplementedException($"ChangedSymbol not implemented for {state}.");
            }
        }
Esempio n. 6
0
        private void Init(string ruleId, ResultLevel level, Message message, string ruleMessageId, FileLocation analysisTarget, IEnumerable <Location> locations, string instanceGuid, string correlationGuid, IDictionary <string, string> partialFingerprints, IDictionary <string, string> fingerprints, IEnumerable <Stack> stacks, IEnumerable <CodeFlow> codeFlows, IEnumerable <Graph> graphs, IEnumerable <GraphTraversal> graphTraversals, IEnumerable <Location> relatedLocations, SuppressionStates suppressionStates, BaselineState baselineState, IEnumerable <Attachment> attachments, IEnumerable <Uri> workItemUris, IEnumerable <PhysicalLocation> conversionProvenance, IEnumerable <Fix> fixes, IDictionary <string, SerializedPropertyInfo> properties)
        {
            RuleId = ruleId;
            Level  = level;
            if (message != null)
            {
                Message = new Message(message);
            }

            RuleMessageId = ruleMessageId;
            if (analysisTarget != null)
            {
                AnalysisTarget = new FileLocation(analysisTarget);
            }

            if (locations != null)
            {
                var destination_0 = new List <Location>();
                foreach (var value_0 in locations)
                {
                    if (value_0 == null)
                    {
                        destination_0.Add(null);
                    }
                    else
                    {
                        destination_0.Add(new Location(value_0));
                    }
                }

                Locations = destination_0;
            }

            InstanceGuid    = instanceGuid;
            CorrelationGuid = correlationGuid;
            if (partialFingerprints != null)
            {
                PartialFingerprints = new Dictionary <string, string>(partialFingerprints);
            }

            if (fingerprints != null)
            {
                Fingerprints = new Dictionary <string, string>(fingerprints);
            }

            if (stacks != null)
            {
                var destination_1 = new List <Stack>();
                foreach (var value_1 in stacks)
                {
                    if (value_1 == null)
                    {
                        destination_1.Add(null);
                    }
                    else
                    {
                        destination_1.Add(new Stack(value_1));
                    }
                }

                Stacks = destination_1;
            }

            if (codeFlows != null)
            {
                var destination_2 = new List <CodeFlow>();
                foreach (var value_2 in codeFlows)
                {
                    if (value_2 == null)
                    {
                        destination_2.Add(null);
                    }
                    else
                    {
                        destination_2.Add(new CodeFlow(value_2));
                    }
                }

                CodeFlows = destination_2;
            }

            if (graphs != null)
            {
                var destination_3 = new List <Graph>();
                foreach (var value_3 in graphs)
                {
                    if (value_3 == null)
                    {
                        destination_3.Add(null);
                    }
                    else
                    {
                        destination_3.Add(new Graph(value_3));
                    }
                }

                Graphs = destination_3;
            }

            if (graphTraversals != null)
            {
                var destination_4 = new List <GraphTraversal>();
                foreach (var value_4 in graphTraversals)
                {
                    if (value_4 == null)
                    {
                        destination_4.Add(null);
                    }
                    else
                    {
                        destination_4.Add(new GraphTraversal(value_4));
                    }
                }

                GraphTraversals = destination_4;
            }

            if (relatedLocations != null)
            {
                var destination_5 = new List <Location>();
                foreach (var value_5 in relatedLocations)
                {
                    if (value_5 == null)
                    {
                        destination_5.Add(null);
                    }
                    else
                    {
                        destination_5.Add(new Location(value_5));
                    }
                }

                RelatedLocations = destination_5;
            }

            SuppressionStates = suppressionStates;
            BaselineState     = baselineState;
            if (attachments != null)
            {
                var destination_6 = new List <Attachment>();
                foreach (var value_6 in attachments)
                {
                    if (value_6 == null)
                    {
                        destination_6.Add(null);
                    }
                    else
                    {
                        destination_6.Add(new Attachment(value_6));
                    }
                }

                Attachments = destination_6;
            }

            if (workItemUris != null)
            {
                var destination_7 = new List <Uri>();
                foreach (var value_7 in workItemUris)
                {
                    destination_7.Add(value_7);
                }

                WorkItemUris = destination_7;
            }

            if (conversionProvenance != null)
            {
                var destination_8 = new List <PhysicalLocation>();
                foreach (var value_8 in conversionProvenance)
                {
                    if (value_8 == null)
                    {
                        destination_8.Add(null);
                    }
                    else
                    {
                        destination_8.Add(new PhysicalLocation(value_8));
                    }
                }

                ConversionProvenance = destination_8;
            }

            if (fixes != null)
            {
                var destination_9 = new List <Fix>();
                foreach (var value_9 in fixes)
                {
                    if (value_9 == null)
                    {
                        destination_9.Add(null);
                    }
                    else
                    {
                        destination_9.Add(new Fix(value_9));
                    }
                }

                Fixes = destination_9;
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Result" /> class from the supplied values.
 /// </summary>
 /// <param name="ruleId">
 /// An initialization value for the <see cref="P: RuleId" /> property.
 /// </param>
 /// <param name="level">
 /// An initialization value for the <see cref="P: Level" /> property.
 /// </param>
 /// <param name="message">
 /// An initialization value for the <see cref="P: Message" /> property.
 /// </param>
 /// <param name="ruleMessageId">
 /// An initialization value for the <see cref="P: RuleMessageId" /> property.
 /// </param>
 /// <param name="analysisTarget">
 /// An initialization value for the <see cref="P: AnalysisTarget" /> property.
 /// </param>
 /// <param name="locations">
 /// An initialization value for the <see cref="P: Locations" /> property.
 /// </param>
 /// <param name="instanceGuid">
 /// An initialization value for the <see cref="P: InstanceGuid" /> property.
 /// </param>
 /// <param name="correlationGuid">
 /// An initialization value for the <see cref="P: CorrelationGuid" /> property.
 /// </param>
 /// <param name="partialFingerprints">
 /// An initialization value for the <see cref="P: PartialFingerprints" /> property.
 /// </param>
 /// <param name="fingerprints">
 /// An initialization value for the <see cref="P: Fingerprints" /> property.
 /// </param>
 /// <param name="stacks">
 /// An initialization value for the <see cref="P: Stacks" /> property.
 /// </param>
 /// <param name="codeFlows">
 /// An initialization value for the <see cref="P: CodeFlows" /> property.
 /// </param>
 /// <param name="graphs">
 /// An initialization value for the <see cref="P: Graphs" /> property.
 /// </param>
 /// <param name="graphTraversals">
 /// An initialization value for the <see cref="P: GraphTraversals" /> property.
 /// </param>
 /// <param name="relatedLocations">
 /// An initialization value for the <see cref="P: RelatedLocations" /> property.
 /// </param>
 /// <param name="suppressionStates">
 /// An initialization value for the <see cref="P: SuppressionStates" /> property.
 /// </param>
 /// <param name="baselineState">
 /// An initialization value for the <see cref="P: BaselineState" /> property.
 /// </param>
 /// <param name="attachments">
 /// An initialization value for the <see cref="P: Attachments" /> property.
 /// </param>
 /// <param name="workItemUris">
 /// An initialization value for the <see cref="P: WorkItemUris" /> property.
 /// </param>
 /// <param name="conversionProvenance">
 /// An initialization value for the <see cref="P: ConversionProvenance" /> property.
 /// </param>
 /// <param name="fixes">
 /// An initialization value for the <see cref="P: Fixes" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P: Properties" /> property.
 /// </param>
 public Result(string ruleId, ResultLevel level, Message message, string ruleMessageId, FileLocation analysisTarget, IEnumerable <Location> locations, string instanceGuid, string correlationGuid, IDictionary <string, string> partialFingerprints, IDictionary <string, string> fingerprints, IEnumerable <Stack> stacks, IEnumerable <CodeFlow> codeFlows, IEnumerable <Graph> graphs, IEnumerable <GraphTraversal> graphTraversals, IEnumerable <Location> relatedLocations, SuppressionStates suppressionStates, BaselineState baselineState, IEnumerable <Attachment> attachments, IEnumerable <Uri> workItemUris, IEnumerable <PhysicalLocation> conversionProvenance, IEnumerable <Fix> fixes, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(ruleId, level, message, ruleMessageId, analysisTarget, locations, instanceGuid, correlationGuid, partialFingerprints, fingerprints, stacks, codeFlows, graphs, graphTraversals, relatedLocations, suppressionStates, baselineState, attachments, workItemUris, conversionProvenance, fixes, properties);
 }
Esempio n. 8
0
        private void Init(string ruleId, string ruleKey, ResultLevel level, string message, FormattedRuleMessage formattedRuleMessage, IEnumerable <Location> locations, string snippet, string id, string toolFingerprintContribution, IEnumerable <Stack> stacks, IEnumerable <CodeFlow> codeFlows, IEnumerable <AnnotatedCodeLocation> relatedLocations, SuppressionStates suppressionStates, BaselineState baselineState, IEnumerable <Fix> fixes, IDictionary <string, SerializedPropertyInfo> properties)
        {
            RuleId  = ruleId;
            RuleKey = ruleKey;
            Level   = level;
            Message = message;
            if (formattedRuleMessage != null)
            {
                FormattedRuleMessage = new FormattedRuleMessage(formattedRuleMessage);
            }

            if (locations != null)
            {
                var destination_0 = new List <Location>();
                foreach (var value_0 in locations)
                {
                    if (value_0 == null)
                    {
                        destination_0.Add(null);
                    }
                    else
                    {
                        destination_0.Add(new Location(value_0));
                    }
                }

                Locations = destination_0;
            }

            Snippet = snippet;
            Id      = id;
            ToolFingerprintContribution = toolFingerprintContribution;
            if (stacks != null)
            {
                var destination_1 = new List <Stack>();
                foreach (var value_1 in stacks)
                {
                    if (value_1 == null)
                    {
                        destination_1.Add(null);
                    }
                    else
                    {
                        destination_1.Add(new Stack(value_1));
                    }
                }

                Stacks = destination_1;
            }

            if (codeFlows != null)
            {
                var destination_2 = new List <CodeFlow>();
                foreach (var value_2 in codeFlows)
                {
                    if (value_2 == null)
                    {
                        destination_2.Add(null);
                    }
                    else
                    {
                        destination_2.Add(new CodeFlow(value_2));
                    }
                }

                CodeFlows = destination_2;
            }

            if (relatedLocations != null)
            {
                var destination_3 = new List <AnnotatedCodeLocation>();
                foreach (var value_3 in relatedLocations)
                {
                    if (value_3 == null)
                    {
                        destination_3.Add(null);
                    }
                    else
                    {
                        destination_3.Add(new AnnotatedCodeLocation(value_3));
                    }
                }

                RelatedLocations = destination_3;
            }

            SuppressionStates = suppressionStates;
            BaselineState     = baselineState;
            if (fixes != null)
            {
                var destination_4 = new List <Fix>();
                foreach (var value_4 in fixes)
                {
                    if (value_4 == null)
                    {
                        destination_4.Add(null);
                    }
                    else
                    {
                        destination_4.Add(new Fix(value_4));
                    }
                }

                Fixes = destination_4;
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Result" /> class from the supplied values.
 /// </summary>
 /// <param name="ruleId">
 /// An initialization value for the <see cref="P: RuleId" /> property.
 /// </param>
 /// <param name="ruleKey">
 /// An initialization value for the <see cref="P: RuleKey" /> property.
 /// </param>
 /// <param name="level">
 /// An initialization value for the <see cref="P: Level" /> property.
 /// </param>
 /// <param name="message">
 /// An initialization value for the <see cref="P: Message" /> property.
 /// </param>
 /// <param name="formattedRuleMessage">
 /// An initialization value for the <see cref="P: FormattedRuleMessage" /> property.
 /// </param>
 /// <param name="locations">
 /// An initialization value for the <see cref="P: Locations" /> property.
 /// </param>
 /// <param name="snippet">
 /// An initialization value for the <see cref="P: Snippet" /> property.
 /// </param>
 /// <param name="id">
 /// An initialization value for the <see cref="P: Id" /> property.
 /// </param>
 /// <param name="toolFingerprintContribution">
 /// An initialization value for the <see cref="P: ToolFingerprintContribution" /> property.
 /// </param>
 /// <param name="stacks">
 /// An initialization value for the <see cref="P: Stacks" /> property.
 /// </param>
 /// <param name="codeFlows">
 /// An initialization value for the <see cref="P: CodeFlows" /> property.
 /// </param>
 /// <param name="relatedLocations">
 /// An initialization value for the <see cref="P: RelatedLocations" /> property.
 /// </param>
 /// <param name="suppressionStates">
 /// An initialization value for the <see cref="P: SuppressionStates" /> property.
 /// </param>
 /// <param name="baselineState">
 /// An initialization value for the <see cref="P: BaselineState" /> property.
 /// </param>
 /// <param name="fixes">
 /// An initialization value for the <see cref="P: Fixes" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P: Properties" /> property.
 /// </param>
 public Result(string ruleId, string ruleKey, ResultLevel level, string message, FormattedRuleMessage formattedRuleMessage, IEnumerable <Location> locations, string snippet, string id, string toolFingerprintContribution, IEnumerable <Stack> stacks, IEnumerable <CodeFlow> codeFlows, IEnumerable <AnnotatedCodeLocation> relatedLocations, SuppressionStates suppressionStates, BaselineState baselineState, IEnumerable <Fix> fixes, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(ruleId, ruleKey, level, message, formattedRuleMessage, locations, snippet, id, toolFingerprintContribution, stacks, codeFlows, relatedLocations, suppressionStates, baselineState, fixes, properties);
 }
Esempio n. 10
0
        private void Init(string ruleId, int ruleIndex, int extensionIndex, ResultKind kind, FailureLevel level, Message message, ArtifactLocation analysisTarget, IEnumerable <Location> locations, string instanceGuid, string correlationGuid, int occurrenceCount, IDictionary <string, string> partialFingerprints, IDictionary <string, string> fingerprints, IEnumerable <Stack> stacks, IEnumerable <CodeFlow> codeFlows, IDictionary <string, Graph> graphs, IEnumerable <GraphTraversal> graphTraversals, IEnumerable <Location> relatedLocations, SuppressionStates suppressionStates, BaselineState baselineState, double rank, IEnumerable <Attachment> attachments, Uri hostedViewerUri, IEnumerable <Uri> workItemUris, ResultProvenance provenance, IEnumerable <Fix> fixes, IDictionary <string, SerializedPropertyInfo> properties)
        {
            RuleId             = ruleId;
            RuleIndex          = ruleIndex;
            RuleExtensionIndex = extensionIndex;
            Kind  = kind;
            Level = level;
            if (message != null)
            {
                Message = new Message(message);
            }

            if (analysisTarget != null)
            {
                AnalysisTarget = new ArtifactLocation(analysisTarget);
            }

            if (locations != null)
            {
                var destination_0 = new List <Location>();
                foreach (var value_0 in locations)
                {
                    if (value_0 == null)
                    {
                        destination_0.Add(null);
                    }
                    else
                    {
                        destination_0.Add(new Location(value_0));
                    }
                }

                Locations = destination_0;
            }

            InstanceGuid    = instanceGuid;
            CorrelationGuid = correlationGuid;
            OccurrenceCount = occurrenceCount;
            if (partialFingerprints != null)
            {
                PartialFingerprints = new Dictionary <string, string>(partialFingerprints);
            }

            if (fingerprints != null)
            {
                Fingerprints = new Dictionary <string, string>(fingerprints);
            }

            if (stacks != null)
            {
                var destination_1 = new List <Stack>();
                foreach (var value_1 in stacks)
                {
                    if (value_1 == null)
                    {
                        destination_1.Add(null);
                    }
                    else
                    {
                        destination_1.Add(new Stack(value_1));
                    }
                }

                Stacks = destination_1;
            }

            if (codeFlows != null)
            {
                var destination_2 = new List <CodeFlow>();
                foreach (var value_2 in codeFlows)
                {
                    if (value_2 == null)
                    {
                        destination_2.Add(null);
                    }
                    else
                    {
                        destination_2.Add(new CodeFlow(value_2));
                    }
                }

                CodeFlows = destination_2;
            }

            if (graphs != null)
            {
                Graphs = new Dictionary <string, Graph>();
                foreach (var value_3 in graphs)
                {
                    Graphs.Add(value_3.Key, new Graph(value_3.Value));
                }
            }

            if (graphTraversals != null)
            {
                var destination_3 = new List <GraphTraversal>();
                foreach (var value_4 in graphTraversals)
                {
                    if (value_4 == null)
                    {
                        destination_3.Add(null);
                    }
                    else
                    {
                        destination_3.Add(new GraphTraversal(value_4));
                    }
                }

                GraphTraversals = destination_3;
            }

            if (relatedLocations != null)
            {
                var destination_4 = new List <Location>();
                foreach (var value_5 in relatedLocations)
                {
                    if (value_5 == null)
                    {
                        destination_4.Add(null);
                    }
                    else
                    {
                        destination_4.Add(new Location(value_5));
                    }
                }

                RelatedLocations = destination_4;
            }

            SuppressionStates = suppressionStates;
            BaselineState     = baselineState;
            Rank = rank;
            if (attachments != null)
            {
                var destination_5 = new List <Attachment>();
                foreach (var value_6 in attachments)
                {
                    if (value_6 == null)
                    {
                        destination_5.Add(null);
                    }
                    else
                    {
                        destination_5.Add(new Attachment(value_6));
                    }
                }

                Attachments = destination_5;
            }

            if (hostedViewerUri != null)
            {
                HostedViewerUri = new Uri(hostedViewerUri.OriginalString, hostedViewerUri.IsAbsoluteUri ? UriKind.Absolute : UriKind.Relative);
            }

            if (workItemUris != null)
            {
                var destination_6 = new List <Uri>();
                foreach (var value_7 in workItemUris)
                {
                    destination_6.Add(value_7);
                }

                WorkItemUris = destination_6;
            }

            if (provenance != null)
            {
                Provenance = new ResultProvenance(provenance);
            }

            if (fixes != null)
            {
                var destination_7 = new List <Fix>();
                foreach (var value_8 in fixes)
                {
                    if (value_8 == null)
                    {
                        destination_7.Add(null);
                    }
                    else
                    {
                        destination_7.Add(new Fix(value_8));
                    }
                }

                Fixes = destination_7;
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Esempio n. 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Result" /> class from the supplied values.
 /// </summary>
 /// <param name="ruleId">
 /// An initialization value for the <see cref="P:RuleId" /> property.
 /// </param>
 /// <param name="ruleIndex">
 /// An initialization value for the <see cref="P:RuleIndex" /> property.
 /// </param>
 /// <param name="extensionIndex">
 /// An initialization value for the <see cref="P:ExtensionIndex" /> property.
 /// </param>
 /// <param name="kind">
 /// An initialization value for the <see cref="P:Kind" /> property.
 /// </param>
 /// <param name="level">
 /// An initialization value for the <see cref="P:Level" /> property.
 /// </param>
 /// <param name="message">
 /// An initialization value for the <see cref="P:Message" /> property.
 /// </param>
 /// <param name="analysisTarget">
 /// An initialization value for the <see cref="P:AnalysisTarget" /> property.
 /// </param>
 /// <param name="locations">
 /// An initialization value for the <see cref="P:Locations" /> property.
 /// </param>
 /// <param name="instanceGuid">
 /// An initialization value for the <see cref="P:InstanceGuid" /> property.
 /// </param>
 /// <param name="correlationGuid">
 /// An initialization value for the <see cref="P:CorrelationGuid" /> property.
 /// </param>
 /// <param name="occurrenceCount">
 /// An initialization value for the <see cref="P:OccurrenceCount" /> property.
 /// </param>
 /// <param name="partialFingerprints">
 /// An initialization value for the <see cref="P:PartialFingerprints" /> property.
 /// </param>
 /// <param name="fingerprints">
 /// An initialization value for the <see cref="P:Fingerprints" /> property.
 /// </param>
 /// <param name="stacks">
 /// An initialization value for the <see cref="P:Stacks" /> property.
 /// </param>
 /// <param name="codeFlows">
 /// An initialization value for the <see cref="P:CodeFlows" /> property.
 /// </param>
 /// <param name="graphs">
 /// An initialization value for the <see cref="P:Graphs" /> property.
 /// </param>
 /// <param name="graphTraversals">
 /// An initialization value for the <see cref="P:GraphTraversals" /> property.
 /// </param>
 /// <param name="relatedLocations">
 /// An initialization value for the <see cref="P:RelatedLocations" /> property.
 /// </param>
 /// <param name="suppressionStates">
 /// An initialization value for the <see cref="P:SuppressionStates" /> property.
 /// </param>
 /// <param name="baselineState">
 /// An initialization value for the <see cref="P:BaselineState" /> property.
 /// </param>
 /// <param name="rank">
 /// An initialization value for the <see cref="P:Rank" /> property.
 /// </param>
 /// <param name="attachments">
 /// An initialization value for the <see cref="P:Attachments" /> property.
 /// </param>
 /// <param name="hostedViewerUri">
 /// An initialization value for the <see cref="P:HostedViewerUri" /> property.
 /// </param>
 /// <param name="workItemUris">
 /// An initialization value for the <see cref="P:WorkItemUris" /> property.
 /// </param>
 /// <param name="provenance">
 /// An initialization value for the <see cref="P:Provenance" /> property.
 /// </param>
 /// <param name="fixes">
 /// An initialization value for the <see cref="P:Fixes" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public Result(string ruleId, int ruleIndex, int extensionIndex, ResultKind kind, FailureLevel level, Message message, ArtifactLocation analysisTarget, IEnumerable <Location> locations, string instanceGuid, string correlationGuid, int occurrenceCount, IDictionary <string, string> partialFingerprints, IDictionary <string, string> fingerprints, IEnumerable <Stack> stacks, IEnumerable <CodeFlow> codeFlows, IDictionary <string, Graph> graphs, IEnumerable <GraphTraversal> graphTraversals, IEnumerable <Location> relatedLocations, SuppressionStates suppressionStates, BaselineState baselineState, double rank, IEnumerable <Attachment> attachments, Uri hostedViewerUri, IEnumerable <Uri> workItemUris, ResultProvenance provenance, IEnumerable <Fix> fixes, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(ruleId, ruleIndex, extensionIndex, kind, level, message, analysisTarget, locations, instanceGuid, correlationGuid, occurrenceCount, partialFingerprints, fingerprints, stacks, codeFlows, graphs, graphTraversals, relatedLocations, suppressionStates, baselineState, rank, attachments, hostedViewerUri, workItemUris, provenance, fixes, properties);
 }
Esempio n. 12
0
        private void Init(string ruleId, string ruleKey, ResultLevel level, string message, FormattedRuleMessage formattedRuleMessage, IEnumerable<Location> locations, string snippet, string id, string toolFingerprintContribution, IEnumerable<Stack> stacks, IEnumerable<CodeFlow> codeFlows, IEnumerable<AnnotatedCodeLocation> relatedLocations, SuppressionStates suppressionStates, BaselineState baselineState, IEnumerable<Fix> fixes, IDictionary<string, SerializedPropertyInfo> properties)
        {
            RuleId = ruleId;
            RuleKey = ruleKey;
            Level = level;
            Message = message;
            if (formattedRuleMessage != null)
            {
                FormattedRuleMessage = new FormattedRuleMessage(formattedRuleMessage);
            }

            if (locations != null)
            {
                var destination_0 = new List<Location>();
                foreach (var value_0 in locations)
                {
                    if (value_0 == null)
                    {
                        destination_0.Add(null);
                    }
                    else
                    {
                        destination_0.Add(new Location(value_0));
                    }
                }

                Locations = destination_0;
            }

            Snippet = snippet;
            Id = id;
            ToolFingerprintContribution = toolFingerprintContribution;
            if (stacks != null)
            {
                var destination_1 = new List<Stack>();
                foreach (var value_1 in stacks)
                {
                    if (value_1 == null)
                    {
                        destination_1.Add(null);
                    }
                    else
                    {
                        destination_1.Add(new Stack(value_1));
                    }
                }

                Stacks = destination_1;
            }

            if (codeFlows != null)
            {
                var destination_2 = new List<CodeFlow>();
                foreach (var value_2 in codeFlows)
                {
                    if (value_2 == null)
                    {
                        destination_2.Add(null);
                    }
                    else
                    {
                        destination_2.Add(new CodeFlow(value_2));
                    }
                }

                CodeFlows = destination_2;
            }

            if (relatedLocations != null)
            {
                var destination_3 = new List<AnnotatedCodeLocation>();
                foreach (var value_3 in relatedLocations)
                {
                    if (value_3 == null)
                    {
                        destination_3.Add(null);
                    }
                    else
                    {
                        destination_3.Add(new AnnotatedCodeLocation(value_3));
                    }
                }

                RelatedLocations = destination_3;
            }

            SuppressionStates = suppressionStates;
            BaselineState = baselineState;
            if (fixes != null)
            {
                var destination_4 = new List<Fix>();
                foreach (var value_4 in fixes)
                {
                    if (value_4 == null)
                    {
                        destination_4.Add(null);
                    }
                    else
                    {
                        destination_4.Add(new Fix(value_4));
                    }
                }

                Fixes = destination_4;
            }

            if (properties != null)
            {
                Properties = new Dictionary<string, SerializedPropertyInfo>(properties);
            }
        }
Esempio n. 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Result" /> class from the supplied values.
 /// </summary>
 /// <param name="ruleId">
 /// An initialization value for the <see cref="P: RuleId" /> property.
 /// </param>
 /// <param name="ruleKey">
 /// An initialization value for the <see cref="P: RuleKey" /> property.
 /// </param>
 /// <param name="level">
 /// An initialization value for the <see cref="P: Level" /> property.
 /// </param>
 /// <param name="message">
 /// An initialization value for the <see cref="P: Message" /> property.
 /// </param>
 /// <param name="formattedRuleMessage">
 /// An initialization value for the <see cref="P: FormattedRuleMessage" /> property.
 /// </param>
 /// <param name="locations">
 /// An initialization value for the <see cref="P: Locations" /> property.
 /// </param>
 /// <param name="snippet">
 /// An initialization value for the <see cref="P: Snippet" /> property.
 /// </param>
 /// <param name="id">
 /// An initialization value for the <see cref="P: Id" /> property.
 /// </param>
 /// <param name="toolFingerprintContribution">
 /// An initialization value for the <see cref="P: ToolFingerprintContribution" /> property.
 /// </param>
 /// <param name="stacks">
 /// An initialization value for the <see cref="P: Stacks" /> property.
 /// </param>
 /// <param name="codeFlows">
 /// An initialization value for the <see cref="P: CodeFlows" /> property.
 /// </param>
 /// <param name="relatedLocations">
 /// An initialization value for the <see cref="P: RelatedLocations" /> property.
 /// </param>
 /// <param name="suppressionStates">
 /// An initialization value for the <see cref="P: SuppressionStates" /> property.
 /// </param>
 /// <param name="baselineState">
 /// An initialization value for the <see cref="P: BaselineState" /> property.
 /// </param>
 /// <param name="fixes">
 /// An initialization value for the <see cref="P: Fixes" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P: Properties" /> property.
 /// </param>
 public Result(string ruleId, string ruleKey, ResultLevel level, string message, FormattedRuleMessage formattedRuleMessage, IEnumerable<Location> locations, string snippet, string id, string toolFingerprintContribution, IEnumerable<Stack> stacks, IEnumerable<CodeFlow> codeFlows, IEnumerable<AnnotatedCodeLocation> relatedLocations, SuppressionStates suppressionStates, BaselineState baselineState, IEnumerable<Fix> fixes, IDictionary<string, SerializedPropertyInfo> properties)
 {
     Init(ruleId, ruleKey, level, message, formattedRuleMessage, locations, snippet, id, toolFingerprintContribution, stacks, codeFlows, relatedLocations, suppressionStates, baselineState, fixes, properties);
 }