예제 #1
0
        private ImmutableArray <byte> GetBytesEmitted(string source, Platform platform, DebugInformationKind debug, bool deterministic)
        {
            var options = new CSharpCompilationOptions(OutputKind.ConsoleApplication, platform: platform, debugInformationKind: debug);

            if (deterministic)
            {
                options = options.WithFeatures((new[] { "dEtErmInIstIc" }).AsImmutable()); // expect case-insensitivity
            }

            var compilation = CreateCompilation(source, assemblyName: "DeterminismTest", references: new[] { MscorlibRef }, compOptions: options);

            // The resolution of the PE header time date stamp is seconds, and we want to make sure that has an opportunity to change
            // between calls to Emit.
            Thread.Sleep(TimeSpan.FromSeconds(1));

            return(compilation.EmitToArray());
        }
예제 #2
0
 public static CSharpCompilationOptions WithStrictMode(this CSharpCompilationOptions options)
 {
     return(options.WithFeatures(options.Features.Add("strict")));
 }