A game about forced loneliness, made by TACStudios
at master 68 lines 2.2 kB view raw
1/*--------------------------------------------------------------------------------------------- 2 * Copyright (c) Microsoft Corporation. All rights reserved. 3 * Licensed under the MIT License. See License.txt in the project root for license information. 4 *--------------------------------------------------------------------------------------------*/ 5using System; 6using System.IO; 7using Unity.CodeEditor; 8using IOPath = System.IO.Path; 9 10namespace Microsoft.Unity.VisualStudio.Editor 11{ 12 internal interface IVisualStudioInstallation 13 { 14 string Path { get; } 15 bool SupportsAnalyzers { get; } 16 Version LatestLanguageVersionSupported { get; } 17 string[] GetAnalyzers(); 18 CodeEditor.Installation ToCodeEditorInstallation(); 19 bool Open(string path, int line, int column, string solutionPath); 20 IGenerator ProjectGenerator { get; } 21 void CreateExtraFiles(string projectDirectory); 22 } 23 24 internal abstract class VisualStudioInstallation : IVisualStudioInstallation 25 { 26 public string Name { get; set; } 27 public string Path { get; set; } 28 public Version Version { get; set; } 29 public bool IsPrerelease { get; set; } 30 31 public abstract bool SupportsAnalyzers { get; } 32 public abstract Version LatestLanguageVersionSupported { get; } 33 public abstract string[] GetAnalyzers(); 34 public abstract IGenerator ProjectGenerator { get; } 35 public abstract void CreateExtraFiles(string projectDirectory); 36 public abstract bool Open(string path, int line, int column, string solutionPath); 37 38 protected Version GetLatestLanguageVersionSupported(VersionPair[] versions) 39 { 40 if (versions != null) 41 { 42 foreach (var entry in versions) 43 { 44 if (Version >= entry.IdeVersion) 45 return entry.LanguageVersion; 46 } 47 } 48 49 // default to 7.0 50 return new Version(7, 0); 51 } 52 53 protected static string[] GetAnalyzers(string path) 54 { 55 var analyzersDirectory = IOPath.GetFullPath(IOPath.Combine(path, "Analyzers")); 56 57 if (Directory.Exists(analyzersDirectory)) 58 return Directory.GetFiles(analyzersDirectory, "*Analyzers.dll", SearchOption.AllDirectories); 59 60 return Array.Empty<string>(); 61 } 62 63 public CodeEditor.Installation ToCodeEditorInstallation() 64 { 65 return new CodeEditor.Installation() { Name = Name, Path = Path }; 66 } 67 } 68}