Ejemplo n.º 1
0
        public static string SuggestedLanguageVersion(this FileInfo project)
        {
            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            if (!project.Exists)
            {
                throw new FileNotFoundException();
            }

            return(CSharpLanguageSelector.GetCSharpLanguageVersion(project.GetTargetFramework()));
        }
Ejemplo n.º 2
0
        public static void TrySetLanguageVersion(this FileInfo project, string version)
        {
            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            if (!project.Exists)
            {
                throw new FileNotFoundException();
            }

            var supported = CSharpLanguageSelector.GetCSharpLanguageVersion(project.GetTargetFramework());

            var canSet = StringComparer.OrdinalIgnoreCase.Equals(supported, version);

            if (canSet)
            {
                project.SetLanguageVersion(version);
            }
        }