• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# LanguageVersion类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中LanguageVersion的典型用法代码示例。如果您正苦于以下问题:C# LanguageVersion类的具体用法?C# LanguageVersion怎么用?C# LanguageVersion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LanguageVersion类属于命名空间,在下文中一共展示了LanguageVersion类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: VerifyCSharpFixAsync

 /// <summary>
 /// Called to test a C# codefix when applied on the inputted string as a source
 /// </summary>
 /// <param name="oldSource">A class in the form of a string before the CodeFix was applied to it</param>
 /// <param name="newSource">A class in the form of a string after the CodeFix was applied to it</param>
 /// <param name="codeFixIndex">Index determining which codefix to apply if there are multiple</param>
 /// <param name="allowNewCompilerDiagnostics">A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied</param>
 /// <param name="formatBeforeCompare">Format the code before comparing, bot the old source and the new.</param>
 /// <param name="codeFixProvider">The codefix to be applied to the code wherever the relevant Diagnostic is found</param>
 /// <param name="languageVersionCSharp">C# language version used for compiling the test project, required unless you inform the VB language version.</param>
 protected async Task VerifyCSharpFixAsync(string oldSource, string newSource, int? codeFixIndex = null, bool allowNewCompilerDiagnostics = false, bool formatBeforeCompare = true, CodeFixProvider codeFixProvider = null, LanguageVersion languageVersionCSharp = LanguageVersion.CSharp6)
 {
     if (formatBeforeCompare)
     {
         oldSource = await FormatSourceAsync(LanguageNames.CSharp, oldSource, languageVersionCSharp).ConfigureAwait(true);
         newSource = await FormatSourceAsync(LanguageNames.CSharp, newSource, languageVersionCSharp).ConfigureAwait(true);
     }
     codeFixProvider = codeFixProvider ?? GetCodeFixProvider();
     var diagnosticAnalyzer = GetDiagnosticAnalyzer();
     if (diagnosticAnalyzer != null)
         await VerifyFixAsync(LanguageNames.CSharp, diagnosticAnalyzer, codeFixProvider, oldSource, newSource, codeFixIndex, allowNewCompilerDiagnostics, languageVersionCSharp, Microsoft.CodeAnalysis.VisualBasic.LanguageVersion.VisualBasic14).ConfigureAwait(true);
     else
         await VerifyFixAsync(LanguageNames.CSharp, codeFixProvider.FixableDiagnosticIds, codeFixProvider, oldSource, newSource, codeFixIndex, allowNewCompilerDiagnostics, languageVersionCSharp, Microsoft.CodeAnalysis.VisualBasic.LanguageVersion.VisualBasic14).ConfigureAwait(true);
 }
开发者ID:Cadums01,项目名称:code-cracker,代码行数:24,代码来源:CodeFixVerifier.cs


示例2: CSharpProject

 public CSharpProject(string projectFile)
 {
     if (!File.Exists(projectFile))
         throw new Exception(string.Format("project file not found \"{0}\"", projectFile));
     WriteLine(1, "compile project \"{0}\"", projectFile);
     _projectFile = projectFile;
     _projectDirectory = Path.GetDirectoryName(projectFile);
     _projectDocument = XDocument.Load(projectFile);
     _frameworkDirectory = GetValue("FrameworkDirectory");
     WriteLine(2, "  framework directory               : \"{0}\"", _frameworkDirectory);
     _assemblyName = GetValue("AssemblyName");
     WriteLine(2, "  assembly name                     : \"{0}\"", _assemblyName);
     string outputDirectory = PathCombine(_projectDirectory, GetValue("OutputDirectory"));
     WriteLine(2, "  output directory                  : \"{0}\"", outputDirectory);
     _languageVersion = GetLanguageVersion(GetValue("LanguageVersion"));
     WriteLine(2, "  language version                  : \"{0}\"", _languageVersion);
     _outputKind = GetOutputKind(GetValue("OutputKind"));
     WriteLine(2, "  output kind                       : \"{0}\"", _outputKind);
     _optimizationLevel = GetOptimizationLevel(GetValue("OptimizationLevel"));
     WriteLine(2, "  optimization level                : \"{0}\"", _optimizationLevel);
     _platform = GetPlatform(GetValue("Platform"));
     WriteLine(2, "  platform                          : \"{0}\"", _platform);
     _generalDiagnosticOption = ReportDiagnostic.Default;
     WriteLine(2, "  general diagnostic option         : \"{0}\"", _generalDiagnosticOption);
     _warningLevel = 4;
     WriteLine(2, "  warning level                     : \"{0}\"", _warningLevel);
     _outputPath = PathCombine(outputDirectory, GetValue("OutputPath"));
     WriteLine(2, "  output path                       : \"{0}\"", _outputPath);
     _pdbPath = PathCombine(outputDirectory, GetValue("PdbPath"));
     WriteLine(2, "  pdb path                          : \"{0}\"", _pdbPath);
     _win32ResourceFile = PathCombine(_projectDirectory, GetValue("Win32ResourceFile"));
     WriteLine(2, "  win32 resource file               : \"{0}\"", _win32ResourceFile);
     _preprocessorSymbols = GetPreprocessorSymbols();
     _sourceFiles = GetSources();
     _resourceFiles = GetResourceFiles();
     _assembliesFiles = GetAssembliesFiles();
 }
开发者ID:labeuze,项目名称:source,代码行数:37,代码来源:CSharpProject.cs


示例3: Copy

 public ParseOptions Copy(
     CompatibilityMode? compatibility = null,
     LanguageVersion? languageVersion = null,
     IEnumerable<string> preprocessorSymbols = null,
     bool? suppressDocumentationCommentParse = null,
     SourceCodeKind? kind = SourceCodeKind.Regular)
 {
     return new ParseOptions(
         compatibility ?? this.Compatibility,
         languageVersion ?? this.LanguageVersion,
         preprocessorSymbols ?? this.PreprocessorSymbols.AsEnumerable(),
         suppressDocumentationCommentParse ?? this.SuppressDocumentationCommentParse,
         kind ?? this.Kind
     );
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:15,代码来源:Options.cs


示例4: CompilerSettings

		public CompilerSettings ()
		{
			StdLib = true;
			Target = Target.Exe;
			TargetExt = ".exe";
			Platform = Platform.AnyCPU;
			Version = LanguageVersion.Default;
			VerifyClsCompliance = true;
			Encoding = Encoding.UTF8;
			LoadDefaultReferences = true;
			StdLibRuntimeVersion = RuntimeVersion.v4;
			WarningLevel = 4;

			// Default to 1 or mdb files would be platform speficic
			TabSize = 1;

			AssemblyReferences = new List<string> ();
			AssemblyReferencesAliases = new List<Tuple<string, string>> ();
			Modules = new List<string> ();
			ReferencesLookupPaths = new List<string> ();

			conditional_symbols = new List<string> ();
			//
			// Add default mcs define
			//
			conditional_symbols.Add ("__MonoCS__");

			source_files = new List<SourceFile> ();
		}
开发者ID:OpenFlex,项目名称:playscript-mono,代码行数:29,代码来源:settings.cs


示例5: Reset

        public static void Reset(bool full)
        {
            impl_details_class = null;
            helper_classes = null;

            if (!full)
                return;

            EntryPoint = null;
            Checked = false;
            Unsafe = false;
            StdLib = true;
            StrongNameKeyFile = null;
            StrongNameKeyContainer = null;
            StrongNameDelaySign = false;
            MainClass = null;
            Target = Target.Exe;
            TargetExt = ".exe";
            Platform = Platform.AnyCPU;
            Version = LanguageVersion.Default;
            Documentation = null;
            impl_details_class = null;
            helper_classes = null;

            #if NET_4_0
            MetadataCompatibilityVersion = MetadataVersion.v4;
            #else
            MetadataCompatibilityVersion = MetadataVersion.v2;
            #endif

            //
            // Setup default defines
            //
            AllDefines = new List<string> ();
            AddConditional ("__MonoCS__");
        }
开发者ID:speier,项目名称:shake,代码行数:36,代码来源:rootcontext.cs


示例6: GetSortedDiagnosticsAsync

 /// <summary>
 /// Given classes in the form of strings, their language, and an IDiagnosticAnlayzer to apply to it, return the diagnostics found in the string after converting it to a document.
 /// </summary>
 /// <param name="sources">Classes in the form of strings</param>
 /// <param name="language">The language the soruce classes are in</param>
 /// <param name="analyzer">The analyzer to be run on the sources</param>
 /// <param name="languageVersionCSharp">C# language version used for compiling the test project, required unless you inform the VB language version.</param>
 /// <param name="languageVersionVB">VB language version used for compiling the test project, required unless you inform the C# language version.</param>
 /// <returns>An IEnumerable of Diagnostics that surfaced in teh source code, sorted by Location</returns>
 private static async Task<Diagnostic[]> GetSortedDiagnosticsAsync(string[] sources, string language, DiagnosticAnalyzer analyzer, LanguageVersion languageVersionCSharp, Microsoft.CodeAnalysis.VisualBasic.LanguageVersion languageVersionVB) =>
     await GetSortedDiagnosticsFromDocumentsAsync(analyzer, GetDocuments(sources, language, languageVersionCSharp, languageVersionVB)).ConfigureAwait(true);
开发者ID:haroldhues,项目名称:code-cracker,代码行数:11,代码来源:DiagnosticVerifier.Helper.cs


示例7: CreateProject

        /// <summary>
        /// Create a project using the inputted strings as sources.
        /// </summary>
        /// <param name="sources">Classes in the form of strings</param>
        /// <param name="language">The language the source code is in</param>
        /// <param name="languageVersionCSharp">C# language version used for compiling the test project, required unless you inform the VB language version.</param>
        /// <param name="languageVersionVB">VB language version used for compiling the test project, required unless you inform the C# language version.</param>
        /// <returns>A Project created out of the Douments created from the source strings</returns>
        public static Project CreateProject(string[] sources,
            string language,
            LanguageVersion languageVersionCSharp,
            Microsoft.CodeAnalysis.VisualBasic.LanguageVersion languageVersionVB)
        {
            var fileNamePrefix = DefaultFilePathPrefix;
            string fileExt;
            ParseOptions parseOptions;
            if (language == LanguageNames.CSharp)
            {
                fileExt = CSharpDefaultFileExt;
                parseOptions = new CSharpParseOptions(languageVersionCSharp);
            }
            else
            {
                fileExt = VisualBasicDefaultExt;
                parseOptions = new Microsoft.CodeAnalysis.VisualBasic.VisualBasicParseOptions(languageVersionVB);
            }

            var projectId = ProjectId.CreateNewId(debugName: TestProjectName);
#pragma warning disable CC0022
            var workspace = new AdhocWorkspace();
#pragma warning restore CC0022

            var projectInfo = ProjectInfo.Create(projectId, VersionStamp.Create(), TestProjectName,
                TestProjectName, language,
                parseOptions: parseOptions,
                metadataReferences: ImmutableList.Create(
                    CorlibReference, SystemCoreReference, RegexReference,
                    CSharpSymbolsReference, CodeAnalysisReference, JsonNetReference));

            workspace.AddProject(projectInfo);

            var count = 0;
            foreach (var source in sources)
            {
                var newFileName = fileNamePrefix + count + "." + fileExt;
                workspace.AddDocument(projectId, newFileName, SourceText.From(source));
                count++;
            }

            var project = workspace.CurrentSolution.GetProject(projectId);
            var newCompilationOptions = project.CompilationOptions.WithSpecificDiagnosticOptions(diagOptions);
            var newSolution = workspace.CurrentSolution.WithProjectCompilationOptions(projectId, newCompilationOptions);
            var newProject = newSolution.GetProject(projectId);
            return newProject;
        }
开发者ID:haroldhues,项目名称:code-cracker,代码行数:55,代码来源:DiagnosticVerifier.Helper.cs


示例8: GetDocuments

        /// <summary>
        /// Given an array of strings as soruces and a language, turn them into a project and return the documents and spans of it.
        /// </summary>
        /// <param name="sources">Classes in the form of strings</param>
        /// <param name="language">The language the source code is in</param>
        /// <param name="languageVersionCSharp">C# language version used for compiling the test project, required unless you inform the VB language version.</param>
        /// <param name="languageVersionVB">VB language version used for compiling the test project, required unless you inform the C# language version.</param>
        /// <returns>A Tuple containing the Documents produced from the sources and thier TextSpans if relevant</returns>
        public static Document[] GetDocuments(string[] sources, string language, LanguageVersion languageVersionCSharp, Microsoft.CodeAnalysis.VisualBasic.LanguageVersion languageVersionVB)
        {
            if (language != LanguageNames.CSharp && language != LanguageNames.VisualBasic)
                throw new ArgumentException("Unsupported Language");

            for (int i = 0; i < sources.Length; i++)
            {
                var fileName = language == LanguageNames.CSharp ? nameof(Test) + i + ".cs" : nameof(Test) + i + ".vb";
            }

            var project = CreateProject(sources, language, languageVersionCSharp, languageVersionVB);
            var documents = project.Documents.ToArray();

            if (sources.Length != documents.Length)
            {
                throw new SystemException("Amount of sources did not match amount of Documents created");
            }

            return documents;
        }
开发者ID:haroldhues,项目名称:code-cracker,代码行数:28,代码来源:DiagnosticVerifier.Helper.cs


示例9: Reset

		public static void Reset (bool full)
		{
			if (full)
				root = null;
			
			type_container_resolve_order = new ArrayList ();
			EntryPoint = null;
			Checked = false;
			Unsafe = false;
			StdLib = true;
			StrongNameKeyFile = null;
			StrongNameKeyContainer = null;
			StrongNameDelaySign = false;
			MainClass = null;
			Target = Target.Exe;
			TargetExt = ".exe";
#if GMCS_SOURCE
			Platform = Platform.AnyCPU;
#endif
			Version = LanguageVersion.Default;
			Documentation = null;
			impl_details_class = null;
			helper_classes = null;

#if GMCS_SOURCE
			MetadataCompatibilityVersion = MetadataVersion.v2;
#else
			MetadataCompatibilityVersion = MetadataVersion.v1;
#endif

			//
			// Setup default defines
			//
			AllDefines = new ArrayList ();
			AddConditional ("__MonoCS__");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:36,代码来源:rootcontext.cs


示例10: Reset

		public static void Reset (bool full)
		{
			if (!full)
				return;
			
			Checked = false;
			Unsafe = false;
			StdLib = true;
			StrongNameKeyFile = null;
			StrongNameKeyContainer = null;
			StrongNameDelaySign = false;
			MainClass = null;
			OutputFile = null;
			Target = Target.Exe;
			SdkVersion = SdkVersion.v2;
			TargetExt = ".exe";
			Platform = Platform.AnyCPU;
			Version = LanguageVersion.Default;
			VerifyClsCompliance = true;
			Optimize = true;
			Encoding = Encoding.Default;
			Documentation = null;
			GenerateDebugInfo = false;
			ParseOnly = false;
			TokenizeOnly = false;
			Win32IconFile = null;
			Win32ResourceFile = null;
			Resources = null;
			LoadDefaultReferences = true;
			AssemblyReferences = new List<string> ();
			AssemblyReferencesAliases = new List<Tuple<string, string>> ();
			Modules = new List<string> ();
			ReferencesLookupPaths = new List<string> ();
			StdLibRuntimeVersion = RuntimeVersion.v2;

			//
			// Setup default defines
			//
			AllDefines = new List<string> ();
			AddConditional ("__MonoCS__");
		}
开发者ID:rmartinho,项目名称:mono,代码行数:41,代码来源:rootcontext.cs


示例11: CompilerSettings

		public CompilerSettings ()
		{
			StdLib = true;
			Target = Target.Exe;
			TargetExt = ".exe";
			Platform = Platform.AnyCPU;
			Version = LanguageVersion.Default;
			VerifyClsCompliance = true;
			Optimize = true;
			Encoding = Encoding.Default;
			LoadDefaultReferences = true;
			StdLibRuntimeVersion = RuntimeVersion.v4;

			AssemblyReferences = new List<string> ();
			AssemblyReferencesAliases = new List<Tuple<string, string>> ();
			Modules = new List<string> ();
			ReferencesLookupPaths = new List<string> ();
		}
开发者ID:famousthom,项目名称:monodevelop,代码行数:18,代码来源:rootcontext.cs


示例12: ParseOptions

        //warnaserror[+|-]
        //warnaserror[+|-]:<warn list>
        //unsafe[+|-]
        //warn:<n>
        //nowarn:<warn list>

        public ParseOptions(
            CompatibilityMode compatibility = CompatibilityMode.None,
            LanguageVersion languageVersion = CSharp.LanguageVersion.CSharp4,
            IEnumerable<string> preprocessorSymbols = null,
            bool suppressDocumentationCommentParse = false,
            SourceCodeKind kind = SourceCodeKind.Regular)
        {
            if (!compatibility.IsValid())
            {
                throw new ArgumentOutOfRangeException("compatibility");
            }
            if (!languageVersion.IsValid())
            {
                throw new ArgumentOutOfRangeException("languageVersion");
            }
            if (!kind.IsValid())
            {
                throw new ArgumentOutOfRangeException("kind");
            }

            this.Compatibility = compatibility;
            this.LanguageVersion = languageVersion;
            this.PreprocessorSymbols = preprocessorSymbols.AsReadOnlyOrEmpty();
            this.SuppressDocumentationCommentParse = suppressDocumentationCommentParse;
            this.Kind = kind;
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:32,代码来源:Options.cs


示例13: VerifyAsync

        private async Task VerifyAsync(string codeWithMarker, string expectedResult, LanguageVersion langVersion = LanguageVersion.VisualBasic14)
        {
            var textSpans = (IList<TextSpan>)new List<TextSpan>();
            MarkupTestFile.GetSpans(codeWithMarker, out var codeWithoutMarker, out textSpans);

            var document = CreateDocument(codeWithoutMarker, LanguageNames.VisualBasic, langVersion);
            var codeCleanups = CodeCleaner.GetDefaultProviders(document).Where(p => p.Name == PredefinedCodeCleanupProviderNames.RemoveUnnecessaryLineContinuation || p.Name == PredefinedCodeCleanupProviderNames.Format);

            var cleanDocument = await CodeCleaner.CleanupAsync(document, textSpans[0], codeCleanups);

            Assert.Equal(expectedResult, (await cleanDocument.GetSyntaxRootAsync()).ToFullString());
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:12,代码来源:RemoveUnnecessaryLineContinuationTests.cs


示例14: CreateDocument

        private static Document CreateDocument(string code, string language, LanguageVersion langVersion)
        {
            var solution = new AdhocWorkspace().CurrentSolution;
            var projectId = ProjectId.CreateNewId();
            var project = solution
                .AddProject(projectId, "Project", "Project.dll", language)
                .GetProject(projectId);

            var parseOptions = (VisualBasicParseOptions)project.ParseOptions;
            parseOptions = parseOptions.WithLanguageVersion(langVersion);
            project = project.WithParseOptions(parseOptions);

            return project.AddDocument("Document", SourceText.From(code));
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:14,代码来源:RemoveUnnecessaryLineContinuationTests.cs


示例15: VerifyCSharpFixAllAsync

 protected async Task VerifyCSharpFixAllAsync(string oldSource, string newSource, bool allowNewCompilerDiagnostics = false, bool formatBeforeCompare = true, CodeFixProvider codeFixProvider = null, LanguageVersion languageVersionCSharp = LanguageVersion.CSharp6, string equivalenceKey = null)
 {
     if (formatBeforeCompare)
     {
         oldSource = await FormatSourceAsync(LanguageNames.CSharp, oldSource, languageVersionCSharp).ConfigureAwait(true);
         newSource = await FormatSourceAsync(LanguageNames.CSharp, newSource, languageVersionCSharp).ConfigureAwait(true);
     }
     codeFixProvider = codeFixProvider ?? GetCodeFixProvider();
     await VerifyFixAllAsync(LanguageNames.CSharp, GetDiagnosticAnalyzer(), codeFixProvider, oldSource, newSource, allowNewCompilerDiagnostics, languageVersionCSharp, Microsoft.CodeAnalysis.VisualBasic.LanguageVersion.VisualBasic14, equivalenceKey).ConfigureAwait(true);
 }
开发者ID:Cadums01,项目名称:code-cracker,代码行数:10,代码来源:CodeFixVerifier.cs


示例16: CreateDocument

 /// <summary>
 /// Create a Document from a string through creating a project that contains it.
 /// </summary>
 /// <param name="source">Classes in the form of a string</param>
 /// <param name="language">The language the source code is in</param>
 /// <param name="languageVersionCSharp">C# language version used for compiling the test project, required unless you inform the VB language version.</param>
 /// <param name="languageVersionVB">VB language version used for compiling the test project, required unless you inform the C# language version.</param>
 /// <returns>A Document created from the source string</returns>
 public static Document CreateDocument(string source,
     string language,
     LanguageVersion languageVersionCSharp,
     Microsoft.CodeAnalysis.VisualBasic.LanguageVersion languageVersionVB) =>
     CreateProject(new[] { source }, language, languageVersionCSharp, languageVersionVB).Documents.First();
开发者ID:haroldhues,项目名称:code-cracker,代码行数:13,代码来源:DiagnosticVerifier.Helper.cs


示例17: VerifyFixAllAsync

 private async static Task VerifyFixAllAsync(string language, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider, string oldSource, string newSource, bool allowNewCompilerDiagnostics, LanguageVersion languageVersionCSharp, Microsoft.CodeAnalysis.VisualBasic.LanguageVersion languageVersionVB, string equivalenceKey = null)
 {
     var document = CreateDocument(oldSource, language, languageVersionCSharp, languageVersionVB);
     var compilerDiagnostics = await GetCompilerDiagnosticsAsync(document).ConfigureAwait(true);
     var getDocumentDiagnosticsAsync = analyzer != null
         ? (Func<Document, ImmutableHashSet<string>, CancellationToken, Task<IEnumerable<Diagnostic>>>)(async (doc, ids, ct) =>
              await GetSortedDiagnosticsFromDocumentsAsync(analyzer, new[] { doc }).ConfigureAwait(true))
         : (async (doc, ids, ct) =>
         {
             var compilerDiags = await GetCompilerDiagnosticsAsync(doc).ConfigureAwait(true);
             return compilerDiags.Where(d => codeFixProvider.FixableDiagnosticIds.Contains(d.Id));
         });
     Func<Project, bool, ImmutableHashSet<string>, CancellationToken, Task<IEnumerable<Diagnostic>>> getProjectDiagnosticsAsync = async (proj, b, ids, ct) =>
     {
         var theDocs = proj.Documents;
         var diags = await Task.WhenAll(theDocs.Select(d => getDocumentDiagnosticsAsync?.Invoke(d, ids, ct))).ConfigureAwait(true);
         return diags.SelectMany(d => d);
     };
     var fixAllProvider = codeFixProvider.GetFixAllProvider();
     var fixAllDiagnosticProvider = new FixAllDiagnosticProvider(codeFixProvider.FixableDiagnosticIds.ToImmutableHashSet(), getDocumentDiagnosticsAsync, getProjectDiagnosticsAsync);
     if (equivalenceKey == null) equivalenceKey = codeFixProvider.GetType().Name;
     var fixAllContext = new FixAllContext(document, codeFixProvider, FixAllScope.Document,
         equivalenceKey,
         codeFixProvider.FixableDiagnosticIds,
         fixAllDiagnosticProvider,
         CancellationToken.None);
     var action = await fixAllProvider.GetFixAsync(fixAllContext).ConfigureAwait(true);
     if (action == null) throw new Exception("No action supplied for the code fix.");
     document = await ApplyFixAsync(document, action).ConfigureAwait(true);
     //check if applying the code fix introduced any new compiler diagnostics
     var newCompilerDiagnostics = GetNewDiagnostics(compilerDiagnostics, await GetCompilerDiagnosticsAsync(document).ConfigureAwait(true));
     if (!allowNewCompilerDiagnostics && newCompilerDiagnostics.Any())
     {
         // Format and get the compiler diagnostics again so that the locations make sense in the output
         document = document.WithSyntaxRoot(Formatter.Format(await document.GetSyntaxRootAsync().ConfigureAwait(true), Formatter.Annotation, document.Project.Solution.Workspace));
         newCompilerDiagnostics = GetNewDiagnostics(compilerDiagnostics, await GetCompilerDiagnosticsAsync(document).ConfigureAwait(true));
         Assert.True(false, $"Fix introduced new compiler diagnostics:\r\n{string.Join("\r\n", newCompilerDiagnostics.Select(d => d.ToString()))}\r\n\r\nNew document:\r\n{(await document.GetSyntaxRootAsync().ConfigureAwait(true)).ToFullString()}\r\n");
     }
     var actual = await GetStringFromDocumentAsync(document).ConfigureAwait(true);
     Assert.Equal(newSource, actual);
 }
开发者ID:Cadums01,项目名称:code-cracker,代码行数:41,代码来源:CodeFixVerifier.cs


示例18: FormatSourceAsync

 public static async Task<string> FormatSourceAsync(string language, string source, LanguageVersion languageVersionCSharp = LanguageVersion.CSharp6, Microsoft.CodeAnalysis.VisualBasic.LanguageVersion languageVersionVB = Microsoft.CodeAnalysis.VisualBasic.LanguageVersion.VisualBasic14)
 {
     var document = CreateDocument(source, language, languageVersionCSharp, languageVersionVB);
     var newDoc = await Formatter.FormatAsync(document).ConfigureAwait(true);
     return (await newDoc.GetSyntaxRootAsync().ConfigureAwait(true)).ToFullString();
 }
开发者ID:haroldhues,项目名称:code-cracker,代码行数:6,代码来源:DiagnosticVerifier.Helper.cs


示例19: CSCParseOption


//.........这里部分代码省略.........
			}
			return true;

		case "/warn":
			WarningLevel = Int32.Parse (value);
			return true;

		case "/nowarn": {
				string [] warns;

				if (value.Length == 0) {
					Console.WriteLine ("/nowarn requires an argument");
					Environment.Exit (1);
				}

				warns = value.Split (argument_value_separator);
				foreach (string wc in warns) {
					try {
						if (wc.Trim ().Length == 0)
							continue;

						int warn = Int32.Parse (wc);
						if (warn < 1) {
							throw new ArgumentOutOfRangeException ("warn");
						}
						ignore_warning.Add (warn);
					} catch {
						Console.WriteLine (String.Format ("`{0}' is not a valid warning number", wc));
						Environment.Exit (1);
					}
				}
				return true;
			}

		case "/noconfig":
			load_default_config = false;
			return true;

		case "/nostdlib":
		case "/nostdlib+":
			StdLib = false;
			return true;

		case "/nostdlib-":
			StdLib = true;
			return true;

		case "/fullpaths":
			return true;

		case "/keyfile":
			if (value == String.Empty) {
				Console.WriteLine ("{0} requires an argument", arg);
				Environment.Exit (1);
			}
			StrongNameKeyFile = value;
			return true;
		case "/keycontainer":
			if (value == String.Empty) {
				Console.WriteLine ("{0} requires an argument", arg);
				Environment.Exit (1);
			}
			StrongNameKeyContainer = value;
			return true;
		case "/delaysign+":
		case "/delaysign":
			StrongNameDelaySign = true;
			return true;
		case "/delaysign-":
			StrongNameDelaySign = false;
			return true;

		case "/langversion":
			switch (value.ToLower (CultureInfo.InvariantCulture)) {
			case "iso-1":
				Version = LanguageVersion.ISO_1;
				return true;

			case "default":
				Version = LanguageVersion.Default;
				return true;
			case "iso-2":
				Version = LanguageVersion.ISO_2;
				return true;
			case "future":
				Version = LanguageVersion.Future;
				return true;
			}
			Console.WriteLine ("Invalid option `{0}' for /langversion. It must be either `ISO-1', `ISO-2' or `Default'", value);
			Environment.Exit (1);
			return true;

		case "/codepage":
			CodePage = value;
			return true;
		}

		Console.WriteLine ("Failing with : {0}", arg);
		return false;
	}
开发者ID:alaendle,项目名称:mono,代码行数:101,代码来源:genproj.cs


示例20: VerifyCSharpHasNoFixAsync

 /// <summary>
 /// Called to test a C# codefix when it should not had been registered
 /// </summary>
 /// <param name="source">A class in the form of a string before the CodeFix was applied to it</param>
 /// <param name="codeFixProvider">The codefix to be applied to the code wherever the relevant Diagnostic is found</param>
 /// <param name="languageVersionCSharp">C# language version used for compiling the test project, required unless you inform the VB language version.</param>
 protected async Task VerifyCSharpHasNoFixAsync(string source, CodeFixProvider codeFixProvider = null, LanguageVersion languageVersionCSharp = LanguageVersion.CSharp6) =>
     await VerifyHasNoFixAsync(LanguageNames.CSharp, GetDiagnosticAnalyzer(), codeFixProvider ?? GetCodeFixProvider(), source, languageVersionCSharp, Microsoft.CodeAnalysis.VisualBasic.LanguageVersion.VisualBasic14).ConfigureAwait(true);
开发者ID:Cadums01,项目名称:code-cracker,代码行数:8,代码来源:CodeFixVerifier.cs



注:本文中的LanguageVersion类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Languages类代码示例发布时间:2022-05-24
下一篇:
C# LanguageType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap