diff --git a/CHANGELOG.md b/CHANGELOG.md index dbd294a..673f4e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Code Editor Package for Visual Studio +## [2.0.3] - 2020-09-09 + +Project generation: + +Added C#8 language support. +Added UnityProjectGeneratorVersion property. +Local and Embedded packages are now selected by default for generation. +Added support for asmdef root namespace. + +Integration: + +When the user disabled auto-refresh in Unity, do not try to force refresh the Asset database. +Fix Visual Studio detection issues with languages using special characters. + + ## [2.0.2] - 2020-05-27 Added support for solution folders. diff --git a/Editor/Discovery.cs b/Editor/Discovery.cs index e6f56cd..6ef89b9 100644 --- a/Editor/Discovery.cs +++ b/Editor/Discovery.cs @@ -140,7 +140,7 @@ namespace Microsoft.Unity.VisualStudio.Editor StartInfo = new ProcessStartInfo { FileName = progpath, - Arguments = "-prerelease -format json", + Arguments = "-prerelease -format json -utf8", UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true, diff --git a/Editor/ProjectGeneration/AssemblyNameProvider.cs b/Editor/ProjectGeneration/AssemblyNameProvider.cs index a663067..ebe3f6d 100644 --- a/Editor/ProjectGeneration/AssemblyNameProvider.cs +++ b/Editor/ProjectGeneration/AssemblyNameProvider.cs @@ -25,7 +25,9 @@ namespace Microsoft.Unity.VisualStudio.Editor public class AssemblyNameProvider : IAssemblyNameProvider { - ProjectGenerationFlag m_ProjectGenerationFlag = (ProjectGenerationFlag)EditorPrefs.GetInt("unity_project_generation_flag", 0); + ProjectGenerationFlag m_ProjectGenerationFlag = (ProjectGenerationFlag)EditorPrefs.GetInt( + "unity_project_generation_flag", + (int)(ProjectGenerationFlag.Local | ProjectGenerationFlag.Embedded)); public string[] ProjectSupportedExtensions => EditorSettings.projectGenerationUserExtensions; @@ -52,15 +54,24 @@ namespace Microsoft.Unity.VisualStudio.Editor { if (assembly.sourceFiles.Any(shouldFileBePartOfSolution)) { - yield return new Assembly(assembly.name, @"Temp\Bin\Debug\", assembly.sourceFiles, new[] { "DEBUG", "TRACE" }.Concat(assembly.defines).Concat(EditorUserBuildSettings.activeScriptCompilationDefines).ToArray(), assembly.assemblyReferences, assembly.compiledAssemblyReferences, assembly.flags) - { - compilerOptions = - { - ResponseFiles = assembly.compilerOptions.ResponseFiles, - AllowUnsafeCode = assembly.compilerOptions.AllowUnsafeCode, - ApiCompatibilityLevel = assembly.compilerOptions.ApiCompatibilityLevel - } + var options = new ScriptCompilerOptions() + { + ResponseFiles = assembly.compilerOptions.ResponseFiles, + AllowUnsafeCode = assembly.compilerOptions.AllowUnsafeCode, + ApiCompatibilityLevel = assembly.compilerOptions.ApiCompatibilityLevel }; + + yield return new Assembly(assembly.name, @"Temp\Bin\Debug\", + assembly.sourceFiles, new[] { "DEBUG", "TRACE" }.Concat(assembly.defines).Concat(EditorUserBuildSettings.activeScriptCompilationDefines).ToArray(), + assembly.assemblyReferences, + assembly.compiledAssemblyReferences, + assembly.flags, +#if UNITY_2020_2_OR_NEWER + options, + assembly.rootNamespace); +#else + options); +#endif } } @@ -68,15 +79,25 @@ namespace Microsoft.Unity.VisualStudio.Editor { foreach (var assembly in CompilationPipeline.GetAssemblies(AssembliesType.Player).Where(assembly => assembly.sourceFiles.Any(shouldFileBePartOfSolution))) { - yield return new Assembly(assembly.name, @"Temp\Bin\Debug\Player\", assembly.sourceFiles, new[] { "DEBUG", "TRACE" }.Concat(assembly.defines).ToArray(), assembly.assemblyReferences, assembly.compiledAssemblyReferences, assembly.flags) - { - compilerOptions = - { - ResponseFiles = assembly.compilerOptions.ResponseFiles, - AllowUnsafeCode = assembly.compilerOptions.AllowUnsafeCode, - ApiCompatibilityLevel = assembly.compilerOptions.ApiCompatibilityLevel - } + var options = new ScriptCompilerOptions() + { + ResponseFiles = assembly.compilerOptions.ResponseFiles, + AllowUnsafeCode = assembly.compilerOptions.AllowUnsafeCode, + ApiCompatibilityLevel = assembly.compilerOptions.ApiCompatibilityLevel }; + + yield return new Assembly(assembly.name, @"Temp\Bin\Debug\Player\", + assembly.sourceFiles, + new[] { "DEBUG", "TRACE" }.Concat(assembly.defines).ToArray(), + assembly.assemblyReferences, + assembly.compiledAssemblyReferences, + assembly.flags, +#if UNITY_2020_2_OR_NEWER + options, + assembly.rootNamespace); +#else + options); +#endif } } } diff --git a/Editor/ProjectGeneration/ProjectGeneration.cs b/Editor/ProjectGeneration/ProjectGeneration.cs index 18a625e..2f39944 100644 --- a/Editor/ProjectGeneration/ProjectGeneration.cs +++ b/Editor/ProjectGeneration/ProjectGeneration.cs @@ -517,9 +517,13 @@ namespace Microsoft.Unity.VisualStudio.Editor if (m_CurrentInstallation != null && m_CurrentInstallation.SupportsCSharp8) { - // Current installation is compatible with C# 8. - // But Unity has no support for C# 8 constructs so far, so tell the compiler to accept only C# 7.3 or lower. + // Current VS installation is compatible with C# 8. + +#if !UNITY_2020_2_OR_NEWER + // Unity 2020.2.0a12 added support for C# 8 + // <=2020.1 has no support for C# 8 constructs, so tell the compiler to accept only C# 7.3 or lower. targetLanguageVersion = "7.3"; +#endif } var projectType = ProjectTypeOf(assembly.name); @@ -535,7 +539,7 @@ namespace Microsoft.Unity.VisualStudio.Editor MSBuildNamespaceUri, assembly.name, assembly.outputPath, - m_AssemblyNameProvider.ProjectGenerationRootNamespace, + GetRootNamespace(assembly), targetFrameworkVersion, targetLanguageVersion, baseDirectory, @@ -544,6 +548,7 @@ namespace Microsoft.Unity.VisualStudio.Editor projectType + ":" + (int)projectType, EditorUserBuildSettings.activeBuildTarget + ":" + (int)EditorUserBuildSettings.activeBuildTarget, Application.unityVersion, + VisualStudioIntegration.PackageVersion() }; try @@ -676,6 +681,7 @@ namespace Microsoft.Unity.VisualStudio.Editor @" ", @" {{E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1}};{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}", @" Package", + @" {17}", @" {14}", @" {15}", @" {16}", @@ -878,6 +884,15 @@ namespace Microsoft.Unity.VisualStudio.Editor { return m_GUIDGenerator.SolutionGuid(m_ProjectName, ScriptingLanguageFor(assembly)); } + + static string GetRootNamespace(Assembly assembly) + { + #if UNITY_2020_2_OR_NEWER + return assembly.rootNamespace; +#else + return EditorSettings.projectGenerationRootNamespace; +#endif + } } public static class SolutionGuidGenerator diff --git a/Editor/VSWhere/vswhere.exe b/Editor/VSWhere/vswhere.exe index ecfb3bf..1731aa6 100644 Binary files a/Editor/VSWhere/vswhere.exe and b/Editor/VSWhere/vswhere.exe differ diff --git a/Editor/VisualStudioIntegration.cs b/Editor/VisualStudioIntegration.cs index 3bd0cfa..8c1bcc3 100644 --- a/Editor/VisualStudioIntegration.cs +++ b/Editor/VisualStudioIntegration.cs @@ -144,7 +144,7 @@ namespace Microsoft.Unity.VisualStudio.Editor } } - private static string PackageVersion() + internal static string PackageVersion() { var package = UnityEditor.PackageManager.PackageInfo.FindForAssembly(typeof(VisualStudioIntegration).Assembly); return package.version; @@ -152,6 +152,10 @@ namespace Microsoft.Unity.VisualStudio.Editor private static void Refresh() { + // If the user disabled auto-refresh in Unity, do not try to force refresh the Asset database + if (!EditorPrefs.GetBool("kAutoRefresh", true)) + return; + RunOnceOnUpdate(AssetDatabase.Refresh); } diff --git a/package.json b/package.json index 1b05135..e380308 100644 --- a/package.json +++ b/package.json @@ -2,19 +2,18 @@ "name": "com.unity.ide.visualstudio", "displayName": "Visual Studio Editor", "description": "Code editor integration for supporting Visual Studio as code editor for unity. Adds support for generating csproj files for intellisense purposes, auto discovery of installations, etc.", - "version": "2.0.2", + "version": "2.0.3", "unity": "2020.1", "unityRelease": "0a12", - "dependencies": {}, "relatedPackages": { - "com.unity.ide.visualstudio.tests": "2.0.2" + "com.unity.ide.visualstudio.tests": "2.0.3" }, "upmCi": { - "footprint": "07f6b10869c0df5a69cfdcba85bf56c904b6d15d" + "footprint": "a528d76d0398bf543d3597af18e87e2f3a13d40a" }, "repository": { "url": "https://github.cds.internal.unity3d.com/unity/com.unity.ide.visualstudio.git", "type": "git", - "revision": "fe4c910c44c62de4bf224f458e3116184d414906" + "revision": "869804bff6e99d0d0e9c1867aebaa070fad875e5" } }