本文整理汇总了C#中TestEnvironment.GetUpdatedCompilationOptionOfSingleProject方法的典型用法代码示例。如果您正苦于以下问题:C# TestEnvironment.GetUpdatedCompilationOptionOfSingleProject方法的具体用法?C# TestEnvironment.GetUpdatedCompilationOptionOfSingleProject怎么用?C# TestEnvironment.GetUpdatedCompilationOptionOfSingleProject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestEnvironment
的用法示例。
在下文中一共展示了TestEnvironment.GetUpdatedCompilationOptionOfSingleProject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProjectSettingsOptionAddAndRemove_CPS
public void ProjectSettingsOptionAddAndRemove_CPS()
{
using (var environment = new TestEnvironment())
using (var project = CSharpHelpers.CreateCSharpCPSProject(environment, "Test", commandLineArguments: @"/warnaserror:CS1111"))
{
var options = environment.GetUpdatedCompilationOptionOfSingleProject();
Assert.Equal(expected: ReportDiagnostic.Error, actual: options.SpecificDiagnosticOptions["CS1111"]);
project.SetCommandLineArguments(@"/warnaserror");
options = environment.GetUpdatedCompilationOptionOfSingleProject();
Assert.False(options.SpecificDiagnosticOptions.ContainsKey("CS1111"));
}
}
示例2: ProjectSettingsOptionAddAndRemove
public void ProjectSettingsOptionAddAndRemove()
{
using (var environment = new TestEnvironment())
{
var project = CSharpHelpers.CreateCSharpProject(environment, "Test");
project.SetOptionWithMarshaledValue(CompilerOptions.OPTID_WARNASERRORLIST, "1111");
var options = environment.GetUpdatedCompilationOptionOfSingleProject();
Assert.Equal(expected: ReportDiagnostic.Error, actual: options.SpecificDiagnosticOptions["CS1111"]);
project.SetOptionWithMarshaledValue(CompilerOptions.OPTID_WARNASERRORLIST, null);
options = environment.GetUpdatedCompilationOptionOfSingleProject();
Assert.False(options.SpecificDiagnosticOptions.ContainsKey("CS1111"));
}
}
示例3: RuleSet_ProjectSettingsOverrideSpecificOptionsAndRestore
public void RuleSet_ProjectSettingsOverrideSpecificOptionsAndRestore()
{
string ruleSetSource = @"<?xml version=""1.0"" encoding=""utf-8""?>
<RuleSet Name=""Ruleset1"" Description=""Test"" ToolsVersion=""12.0"">
<IncludeAll Action=""Warning"" />
<Rules AnalyzerId=""Microsoft.Analyzers.ManagedCodeAnalysis"" RuleNamespace=""Microsoft.Rules.Managed"">
<Rule Id=""CS1014"" Action=""None"" />
</Rules>
</RuleSet>
";
using (var ruleSetFile = new DisposableFile())
using (var environment = new TestEnvironment())
{
File.WriteAllText(ruleSetFile.Path, ruleSetSource);
var project = CSharpHelpers.CreateCSharpProject(environment, "Test");
project.SetRuleSetFile(ruleSetFile.Path);
project.SetOptionWithMarshaledValue(CompilerOptions.OPTID_WARNASERRORLIST, "1014");
var options = environment.GetUpdatedCompilationOptionOfSingleProject();
Assert.Equal(expected: ReportDiagnostic.Error, actual: options.SpecificDiagnosticOptions["CS1014"]);
project.SetOptionWithMarshaledValue(CompilerOptions.OPTID_WARNNOTASERRORLIST, "1014");
options = environment.GetUpdatedCompilationOptionOfSingleProject();
Assert.Equal(expected: ReportDiagnostic.Suppress, actual: options.SpecificDiagnosticOptions["CS1014"]);
project.SetOptionWithMarshaledValue(CompilerOptions.OPTID_WARNNOTASERRORLIST, null);
options = environment.GetUpdatedCompilationOptionOfSingleProject();
Assert.Equal(expected: ReportDiagnostic.Error, actual: options.SpecificDiagnosticOptions["CS1014"]);
project.SetOptionWithMarshaledValue(CompilerOptions.OPTID_WARNASERRORLIST, null);
options = environment.GetUpdatedCompilationOptionOfSingleProject();
Assert.Equal(expected: ReportDiagnostic.Suppress, actual: options.SpecificDiagnosticOptions["CS1014"]);
}
}