当前位置: 首页>>代码示例>>C#>>正文


C# LanguageVersion类代码示例

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


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


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