Example #1
0
        private static bool TryFixBenchmarkAttribute(
            AnnotateContext annotateContext,
            string fileName, int firstCodeLine,
            CompetitionTarget competitionTarget,
            CompetitionState competitionState)
        {
            var sourceFileLines = annotateContext.TryGetFileLines(fileName, competitionState);

            if (sourceFileLines.Count == 0)
            {
                return(false);
            }

            bool attributeFixed = false;

            for (var i = firstCodeLine - 2; i >= 0; i--)
            {
                var line = sourceFileLines[i];
                if (_breakIfRegex.IsMatch(line))
                {
                    break;
                }

                bool hasMatch = false;
                var  line2    = _attributeRegex.Replace(
                    line,
                    m => FixAttributeContent(m, competitionTarget, out hasMatch), 1);

                if (hasMatch)
                {
                    if (line2 != line)
                    {
                        annotateContext.ReplaceLine(fileName, i, line2);
                    }

                    attributeFixed = true;
                    break;
                }
            }
            return(attributeFixed);
        }