private TestCaseLocation ToTestCaseLocation(SourceFileLocation location, IEnumerable<SourceFileLocation> allTraitSymbols)
 {
     List<Trait> traits = GetTraits(location, allTraitSymbols);
     var testCaseLocation = new TestCaseLocation(location.Symbol, location.Sourcefile, location.Line);
     testCaseLocation.Traits.AddRange(traits);
     return testCaseLocation;
 }
        private List<Trait> GetTraits(SourceFileLocation nativeSymbol, IEnumerable<SourceFileLocation> allTraitSymbols)
        {
            var traits = new List<Trait>();
            // ReSharper disable once LoopCanBeConvertedToQuery
            foreach (SourceFileLocation nativeTraitSymbol in allTraitSymbols)
            {
                int indexOfSerializedTrait = nativeTraitSymbol.Symbol.LastIndexOf("::", StringComparison.Ordinal) + "::".Length;
                string testClassSignature = nativeTraitSymbol.Symbol.Substring(0, indexOfSerializedTrait - "::".Length);
                if (nativeSymbol.Symbol.StartsWith(testClassSignature))
                {
                    int lengthOfSerializedTrait = nativeTraitSymbol.Symbol.Length - indexOfSerializedTrait - TraitAppendix.Length;
                    string serializedTrait = nativeTraitSymbol.Symbol.Substring(indexOfSerializedTrait, lengthOfSerializedTrait);
                    string[] data = serializedTrait.Split(new[] { TraitSeparator }, StringSplitOptions.None);
                    traits.Add(new Trait(data[0], data[1]));
                }
            }

            return traits;
        }
예제 #3
0
        private SourceFileLocation ToSourceFileLocation(NativeSourceFileLocation nativeSymbol)
        {
            IDiaEnumLineNumbers lineNumbers = GetLineNumbers(nativeSymbol.AddressSection, nativeSymbol.AddressOffset, nativeSymbol.Length);

            if (lineNumbers.count <= 0)
            {
                _logger.LogWarning("Failed to locate line number for " + nativeSymbol);
                return(new SourceFileLocation(_binary, "", 0));
            }

            SourceFileLocation result = null;

            foreach (IDiaLineNumber lineNumber in lineNumbers)
            {
                if (result == null)
                {
                    result = new SourceFileLocation(
                        nativeSymbol.Symbol, lineNumber.sourceFile.fileName,
                        lineNumber.lineNumber);
                    // do not break to make sure all lineNumbers are enumerated - not sure if this is necessary
                }
            }
            return(result);
        }
예제 #4
0
        private SourceFileLocation ToSourceFileLocation(NativeSourceFileLocation nativeSymbol)
        {
            IDiaEnumLineNumbers lineNumbers = GetLineNumbers(nativeSymbol.AddressSection, nativeSymbol.AddressOffset, nativeSymbol.Length);

            if (lineNumbers.count > 0)
            {
                SourceFileLocation result = null;
                foreach (IDiaLineNumber lineNumber in lineNumbers)
                {
                    if (result == null)
                    {
                        result = new SourceFileLocation(
                            nativeSymbol.Symbol, lineNumber.sourceFile.fileName,
                            lineNumber.lineNumber);
                    }
                }
                return(result);
            }
            else
            {
                ErrorMessages.Add("Failed to locate line number for " + nativeSymbol);
                return(new SourceFileLocation(Binary, "", 0));
            }
        }
예제 #5
0
        private SourceFileLocation ToSourceFileLocation(NativeSourceFileLocation nativeSymbol)
        {
            IDiaEnumLineNumbers lineNumbers = GetLineNumbers(nativeSymbol.AddressSection, nativeSymbol.AddressOffset, nativeSymbol.Length);
            if (lineNumbers.count <= 0)
            {
                _logger.LogWarning("Failed to locate line number for " + nativeSymbol);
                return new SourceFileLocation(_binary, "", 0);
            }

            SourceFileLocation result = null;
            foreach (IDiaLineNumber lineNumber in lineNumbers)
            {
                if (result == null)
                {
                    result = new SourceFileLocation(
                        nativeSymbol.Symbol, lineNumber.sourceFile.fileName,
                        lineNumber.lineNumber);
                    // do not break to make sure all lineNumbers are enumerated - not sure if this is necessary
                }
            }
            return result;
        }