本文整理汇总了C#中CSharpCompilationOptions.WithStrongNameProvider方法的典型用法代码示例。如果您正苦于以下问题:C# CSharpCompilationOptions.WithStrongNameProvider方法的具体用法?C# CSharpCompilationOptions.WithStrongNameProvider怎么用?C# CSharpCompilationOptions.WithStrongNameProvider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSharpCompilationOptions
的用法示例。
在下文中一共展示了CSharpCompilationOptions.WithStrongNameProvider方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateCompilationOption
private void UpdateCompilationOption(ProjectState state)
{
var context = state.ProjectContext;
var project = context.ProjectFile;
var option = project.GetCompilerOptions(context.TargetFramework, _compilationConfiguration);
var outputKind = option.EmitEntryPoint.GetValueOrDefault() ? OutputKind.ConsoleApplication :
OutputKind.DynamicallyLinkedLibrary;
var generalDiagnosticOpt = (option.WarningsAsErrors ?? false) ? ReportDiagnostic.Error :
ReportDiagnostic.Default;
var optimize = (option.Optimize ?? false) ? OptimizationLevel.Release : OptimizationLevel.Debug;
var csharpOptions = new CSharpCompilationOptions(outputKind)
.WithAllowUnsafe(option.AllowUnsafe ?? false)
.WithPlatform(ParsePlatfrom(option.Platform))
.WithGeneralDiagnosticOption(generalDiagnosticOpt)
.WithOptimizationLevel(optimize)
.WithSpecificDiagnosticOptions(new Dictionary<string, ReportDiagnostic> {
{ "CS1701", ReportDiagnostic.Suppress },
{ "CS1702", ReportDiagnostic.Suppress },
{ "CS1705", ReportDiagnostic.Suppress },
})
.WithConcurrentBuild(false); // TODO: actually just need to disable on mono
if (!string.IsNullOrEmpty(option.KeyFile))
{
var cryptoKeyFile = Path.GetFullPath(Path.Combine(project.ProjectDirectory, option.KeyFile));
if (File.Exists(cryptoKeyFile))
{
var strongNameProvider = new DesktopStrongNameProvider(ImmutableArray.Create(project.ProjectDirectory));
csharpOptions = csharpOptions
.WithStrongNameProvider(strongNameProvider)
.WithCryptoPublicKey(SnkUtils.ExtractPublicKey(File.ReadAllBytes(cryptoKeyFile)));
}
}
var parseOptions = new CSharpParseOptions(languageVersion: ParseLanguageVersion(option.LanguageVersion),
preprocessorSymbols: option.Defines);
_omnisharpWorkspace.SetCompilationOptions(state.Id, csharpOptions);
_omnisharpWorkspace.SetParseOptions(state.Id, parseOptions);
}