Exemple #1
0
        private static bool TryFixBenchmarkAttribute(
            AnnotateContext annotateContext,
            string fileName, int firstCodeLine,
            CompetitionTarget competitionTarget)
        {
            var result          = false;
            var sourceFileLines = annotateContext.GetFileLines(fileName);

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

                var line2 = _attributeRegex.Replace(
                    line,
                    m => FixAttributeContent(m, competitionTarget), 1);
                if (line2 != line)
                {
                    annotateContext.ReplaceLine(fileName, i, line2);
                    result = true;
                    break;
                }
            }
            return(result);
        }
Exemple #2
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);
        }