Skip to content

Instantly share code, notes, and snippets.

@ctaggart
Created November 23, 2014 04:17
Show Gist options
  • Save ctaggart/6c7e48ba5ca6c729fc3b to your computer and use it in GitHub Desktop.
Save ctaggart/6c7e48ba5ca6c729fc3b to your computer and use it in GitHub Desktop.
SourceLink.SymbolStore example
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FSharp.Compiler.Service" version="0.0.76" targetFramework="net45" />
<package id="SourceLink" version="0.4.2" targetFramework="net45" />
<package id="SourceLink.SymbolStore" version="0.5.0-ci1411221733" targetFramework="net45" />
</packages>
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, Finalize
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1738 32
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1738
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, get_Errors
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1740 26
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1740
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, get_HasFullTypeCheckInfo
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetDeclarationListInfo
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1747 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1747
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetDeclarationListSymbols
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1751 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1751
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetToolTipTextAlternate
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1760 13
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1760
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetF1KeywordAlternate
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1765 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1765
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetMethodsAlternate
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1771 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1771
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetDeclarationLocationAlternate
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1776 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1776
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetSymbolUseAtLocation
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1780 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1780
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetSymbolAtLocationAlternate
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1785 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1785
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetExtraColorizationsAlternate
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1791 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1791
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, get_PartialAssemblySignature
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1798 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1798
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, get_ProjectContext
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1805 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1805
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetAllUsesOfAllSymbolsInFile
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1812 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1812
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetUsesOfSymbolInFile
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1818 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1818
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetDeclarations
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1825 224
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1825
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetExtraColorizations
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1829 50
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1829
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetToolTipText
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1833 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1833
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetDataTipText
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1838 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1838
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetDeclarationLocation
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1842 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1842
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetDeclarationLocation
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1847 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1847
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetSymbolAtLocation
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1851 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1851
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetF1Keyword
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1856 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1856
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetMethods
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1861 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1861
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetDeclarationSymbols
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1866 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1866
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetDeclarationsAlternate
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\service.fs 1870 9
https://raw.githubusercontent.com/fsharp/FSharp.Compiler.Service/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs
https://github.com/fsharp/FSharp.Compiler.Service/blob/c2226e5bb72f08561d1af7ad42bd1f614215ebd5/src/fsharp/vs/service.fs#L1870
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, ToString
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\FSharp.Compiler.Service\obj\x86\Release\FSComp.fs 99 53
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, Equals
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\FSharp.Compiler.Service\obj\x86\Release\FSComp.fs 100 53
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetHashCode
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\FSharp.Compiler.Service\obj\x86\Release\FSComp.fs 111 80
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, GetType
C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\FSharp.Compiler.Service\obj\x86\Release\FSComp.fs 114 87
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, Errors
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, HasFullTypeCheckInfo
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, PartialAssemblySignature
Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults, ProjectContext
open System
open System.IO
open SourceLink
open SourceLink.SymbolStore
open System.Reflection
let printfn format = Printf.ksprintf (fun message -> System.Diagnostics.Debug.WriteLine message) format
let pdbFcs = @"..\..\packages\FSharp.Compiler.Service.0.0.76\lib\net45\FSharp.Compiler.Service.pdb"
let dllFcs = @"..\..\packages\FSharp.Compiler.Service.0.0.76\lib\net45\FSharp.Compiler.Service.dll"
let cacheDir = @"..\..\packages"
let printPdbDocuments() =
use pdb = File.OpenRead pdbFcs
let symbolCache = SymbolCache cacheDir
let pdbReader = symbolCache.ReadPdb pdb pdbFcs
for d in pdbReader.Documents do
printfn "\npdb original source file path: %s" d.SourceFilePath
printfn "it had an md5 checksum of: %s" d.ChecksumHex
let url = pdbReader.GetDownloadUrl d.SourceFilePath
if url.IsSome then
let url = url |> Option.get
printfn "has download url if source indexed: %A" url
let downloadedFile = symbolCache.DownloadFile url
printfn "downloaded the file to the cache %s" downloadedFile
printfn "downloaded file has md5 of: %s" (Crypto.hashMD5 downloadedFile |> Hex.encode)
let printMethods() =
use pdb = File.OpenRead pdbFcs
let symbolCache = SymbolCache cacheDir
let pdbReader = symbolCache.ReadPdb pdb pdbFcs
let dll = Assembly.LoadFrom dllFcs
dll.DefinedTypes
// |> Seq.filter (fun dt -> dt.FullName.StartsWith "Microsoft.FSharp.Compiler.SourceCodeServices")
|> Seq.filter (fun dt -> dt.FullName = "Microsoft.FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults")
|> Seq.iter (fun dt ->
for mbr in dt.GetMembers() do
printfn "%s, %s" dt.FullName mbr.Name
match pdbReader.GetMethod mbr.MetadataToken with
| None -> ()
| Some mth ->
for sp in mth.SequencePoints do
printfn " %s %d %d" sp.Document.SourceFilePath sp.Line sp.Column
let url = pdbReader.GetDownloadUrl sp.Document.SourceFilePath
if url.IsSome then
let url = url.Value
printfn " %s" url
let replace (b:string) c (a:string) = a.Replace(b, c)
let browserUrl =
sprintf "%s#L%d"
(url |> replace "raw.githubusercontent" "github" |> replace "Service/" "Service/blob/")
sp.Line
printfn " %s" browserUrl
)
[<EntryPoint>]
let main argv =
printPdbDocuments()
printMethods()
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment