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())); }
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); } }