Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Instrumenter"/> class.
        /// </summary>
        /// <param name="instrumentationConfigFile">Instrumentation configuration filepath. </param>
        /// <param name="runtimeConfigFile">Runtime configuration file path.</param>
        public Instrumenter(string instrumentationConfigFile, string runtimeConfigFile)
        {
            this.instrumentationConfigurationFile = instrumentationConfigFile;
            this.runtimeConfigurationFile         = runtimeConfigFile;
            var configuration = InstrumentationConfiguration.Parse(instrumentationConfigFile);

            this.ilRewriter = new ILRewriter(configuration);

            // a dummy call to force copying TSVDRuntime.dll to the build directory
            TSVDRuntime.Dummy.Call();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Parse config.
        /// </summary>
        /// <param name="configFilePath">Config file path.</param>
        /// <returns>Parsed config object.</returns>
        public static InstrumentationConfiguration Parse(string configFilePath)
        {
            XmlSerializer     serializer = new XmlSerializer(typeof(InstrumentationConfiguration));
            XmlReaderSettings settings   = new XmlReaderSettings();

            using (var reader = XmlReader.Create(configFilePath, settings))
            {
                InstrumentationConfiguration config = serializer.Deserialize(reader) as InstrumentationConfiguration;
                return(config);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ILRewriter"/> class.
        /// </summary>
        /// <param name="configuration">Instrumentation Configuration.</param>
        public ILRewriter(InstrumentationConfiguration configuration)
        {
            this.configuration = configuration;

            string cwd             = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string runtimeAssembly = Path.Combine(cwd, Constants.TSVDRuntimeLibraryFile);

            this.tsvdRuntimeModule  = ModuleDefinition.ReadModule(runtimeAssembly);
            this.interceptionMethod = this.tsvdRuntimeModule
                                      .Types.Single(t => t.Name == Constants.InterceptorType)
                                      .Methods.Single(x => x.Name == Constants.OnStartMethod).Resolve();
        }