private void NotifyFrontend(FrontendBackendHost host, UnityVersion unityVersion, Version version) { host.Do(rd => { // if model is there, then ApplicationPath was already set via UnityEditorProtocol, it would be more // correct than any counted value if (myBackendUnityHost.BackendUnityModel.Value != null) { return; } var info = UnityInstallationFinder.GetApplicationInfo(version, unityVersion); if (info == null) { return; } var contentsPath = UnityInstallationFinder.GetApplicationContentsPath(info.Path); rd.UnityApplicationData.SetValue(new UnityApplicationData(info.Path.FullPath, contentsPath.FullPath, UnityVersion.VersionToString(info.Version), null, null, null)); rd.RequiresRiderPackage.Set(UnityVersion.RequiresRiderPackage(info.Version)); }); }
private void NotifyFrontend(UnityHost host, UnityVersion unityVersion) { host.PerformModelAction(rd => { // if model is there, then ApplicationPath was already set via UnityEditorProtocol, it would be more correct than any counted value if (myUnityEditorProtocol.UnityModel.Value != null) { return; } var version = unityVersion.GetActualVersionForSolution(); var info = UnityInstallationFinder.GetApplicationInfo(version, unityVersion); if (info == null) { return; } var contentsPath = UnityInstallationFinder.GetApplicationContentsPath(info.Path); rd.UnityApplicationData.SetValue(new UnityApplicationData(info.Path.FullPath, contentsPath.FullPath, UnityVersion.VersionToString(info.Version), UnityVersion.RequiresRiderPackage(info.Version) )); }); }
private FileSystemPath GetDocumentationRoot() { var version = mySolutionsManager.Solution?.GetComponent <UnityVersion>().GetActualVersionForSolution(); var contentsPath = myInstallationFinder.GetApplicationContentsPath(version); return(contentsPath == null ? FileSystemPath.Empty : contentsPath.Combine(@"Documentation/en")); }
private static void NotifyFrontend(UnityHost host, UnityVersion unityVersion) { var version = unityVersion.GetActualVersionForSolution(); var info = UnityInstallationFinder.GetApplicationInfo(version); if (info == null) { return; } host.PerformModelAction(rd => { // ApplicationPath may be already set via UnityEditorProtocol, which is more accurate if (!rd.ApplicationPath.HasValue()) { rd.ApplicationPath.SetValue(info.Path.FullPath); } if (!rd.ApplicationContentsPath.HasValue()) { var contentsPath = UnityInstallationFinder.GetApplicationContentsPath(version); if (contentsPath != null) { rd.ApplicationContentsPath.SetValue(contentsPath.FullPath); } } if (!rd.ApplicationVersion.HasValue() && info.Version != null) { rd.ApplicationVersion.SetValue(UnityVersion.VersionToString(info.Version)); } }); }
private FileSystemPath GetDocumentationRoot() { var appPath = mySolutionsManager.Solution?.GetComponent <UnityVersion>().GetActualAppPathForSolution(); var contentsPath = UnityInstallationFinder.GetApplicationContentsPath(appPath); return(contentsPath.Combine(@"Documentation/en")); }
public UnityInstallationSynchronizer(Lifetime lifetime, UnityReferencesTracker referencesTracker, UnityHost host, UnityInstallationFinder finder, UnityVersion unityVersion) { referencesTracker.HasUnityReference.Advise(lifetime, hasReference => { if (!hasReference) { return; } var version = unityVersion.GetActualVersionForSolution(); var path = finder.GetApplicationPath(version); if (path == null) { return; } var contentPath = finder.GetApplicationContentsPath(version); host.PerformModelAction(rd => { // ApplicationPath may be already set via UnityEditorProtocol, which is more accurate if (!rd.ApplicationPath.HasValue()) { rd.ApplicationPath.SetValue(path.FullPath); } if (!rd.ApplicationContentsPath.HasValue()) { rd.ApplicationContentsPath.SetValue(contentPath.FullPath); } }); }); }
private FileSystemPath GetDocumentationRoot() { var appPath = mySolutionsManager.Solution?.GetComponent <UnityVersion>().GetActualAppPathForSolution(); var contentsPath = UnityInstallationFinder.GetApplicationContentsPath(appPath); var root = contentsPath.Combine("Documentation"); var englishRoot = root.Combine("en"); if (!englishRoot.ExistsDirectory) { return(root.GetChildDirectories().FirstOrDefault(englishRoot)); } return(englishRoot); }
public static FileSystemPath GetCgIncludeFolderPath(UnityVersion unityVersion) { var path = unityVersion.GetActualAppPathForSolution(); if (path.IsEmpty) { return(FileSystemPath.Empty); } var contentPath = UnityInstallationFinder.GetApplicationContentsPath(path); return(contentPath.Combine("CGIncludes")); }
private static void NotifyFrontend(UnityHost host, UnityVersion unityVersion) { var version = unityVersion.GetActualVersionForSolution(); var applicationPath = unityVersion.GetActualAppPathForSolution(); if (PlatformUtil.RuntimePlatform == PlatformUtil.Platform.MacOsX && !applicationPath.ExistsDirectory || PlatformUtil.RuntimePlatform != PlatformUtil.Platform.MacOsX && !applicationPath.ExistsFile) { var info = UnityInstallationFinder.GetApplicationInfo(version); if (info == null) { return; } applicationPath = info.Path; version = info.Version; } host.PerformModelAction(rd => { // ApplicationPath may be already set via UnityEditorProtocol, which will obviously be correct if (!rd.ApplicationPath.HasValue()) { rd.ApplicationPath.SetValue(applicationPath.FullPath); } if (!rd.ApplicationContentsPath.HasValue()) { var contentsPath = UnityInstallationFinder.GetApplicationContentsPath(applicationPath); if (!contentsPath.IsEmpty) { rd.ApplicationContentsPath.SetValue(contentsPath.FullPath); } } if (!rd.ApplicationVersion.HasValue() && version != null) { rd.ApplicationVersion.SetValue(UnityVersion.VersionToString(version)); } }); }
private void NotifyFrontend(UnityHost host, UnityVersion unityVersion) { var version = unityVersion.GetActualVersionForSolution(); var applicationPath = unityVersion.GetActualAppPathForSolution(); if (PlatformUtil.RuntimePlatform == PlatformUtil.Platform.MacOsX && !applicationPath.ExistsDirectory || PlatformUtil.RuntimePlatform != PlatformUtil.Platform.MacOsX && !applicationPath.ExistsFile) { var info = UnityInstallationFinder.GetApplicationInfo(version); if (info == null) { return; } applicationPath = info.Path; version = info.Version; } host.PerformModelAction(rd => { // if model is there, then ApplicationPath was already set via UnityEditorProtocol, it would be more correct than any counted value if (myUnityEditorProtocol.UnityModel.Value != null) { return; } rd.ApplicationPath.SetValue(applicationPath.FullPath); var contentsPath = UnityInstallationFinder.GetApplicationContentsPath(applicationPath); if (!contentsPath.IsEmpty) { rd.ApplicationContentsPath.SetValue(contentsPath.FullPath); } if (version != null) { rd.ApplicationVersion.SetValue(UnityVersion.VersionToString(version)); } }); }
public UnityInstallationSynchronizer(Lifetime lifetime, UnitySolutionTracker solutionTracker, UnityHost host, UnityInstallationFinder finder, UnityVersion unityVersion) { solutionTracker.IsUnityProjectFolder.AdviseNotNull(lifetime, isUnityProjectFolder => { if (!isUnityProjectFolder) { return; } var version = unityVersion.GetActualVersionForSolution(); var info = finder.GetApplicationInfo(version); if (info == null) { return; } var contentPath = finder.GetApplicationContentsPath(version); host.PerformModelAction(rd => { // ApplicationPath may be already set via UnityEditorProtocol, which is more accurate if (!rd.ApplicationPath.HasValue()) { rd.ApplicationPath.SetValue(info.Path.FullPath); } if (!rd.ApplicationContentsPath.HasValue()) { rd.ApplicationContentsPath.SetValue(contentPath.FullPath); } if (!rd.ApplicationVersion.HasValue()) { rd.ApplicationVersion.SetValue(UnityVersion.VersionToString(info.Version)); } }); }); }
private void SetProjectLangVersion(IProject project, ISettingsStorageMountPoint mountPoint) { // Only if it's a generated project. Class libraries can use whatever language version they want if (!project.IsUnityGeneratedProject()) { return; } #region Explanation // Make sure we don't suggest code changes that won't compile in Unity due to mismatched C# language levels // (e.g. C#6 "elvis" operator) // // * Unity prior to 5.5 uses an old mono compiler that only supports C# 4 // * Unity 5.5 and later adds C# 6 support as an option. This is enabled by setting // the API compatibility level to NET_4_6 // * The CSharp60Support plugin replaces the compiler with either C# 6 or C# 7.0 or 8.0 // It can be recognised by a folder called `CSharp60Support` or `CSharp70Support` or `CSharp80Support` // in the root of the project // (https://bitbucket.org/alexzzzz/unity-c-5.0-and-6.0-integration) // * Note that since Unity 2017.2 till 2018.3, we've been special-cased in the Unity csproj generation // and we've been getting v4.5 for old runtime and default values (4.7.1) for new. So where // it says 3.5 below, that depends on the version of Unity. Older versions will give us 3.5, // newer versions 4.5. // // Scenarios: // * No VSTU installed (including Unity 5.5) // .csproj has NO `LangVersion`. `TargetFrameworkVersion` will be `v3.5` // * Early versions of VSTU // .csproj has NO `LangVersion`. `TargetFrameworkVersion` will be `v3.5` // * Later versions of VSTU // `LangVersion` is correctly set to "4". `TargetFrameworkVersion` will be `v3.5` // OR `LangVersion` is set to "6" or "latest". // * VSTU for 5.5 // `LangVersion` is set to "default". `TargetFrameworkVersion` will be `v3.5` or `v4.6` // Note that "default" for VS"15" or Rider will be C# 7.0! // * Unity3dRider is installed // Uses Unity's own generation and adds correct `LangVersion` // `TargetFrameworkVersion` will be correct for the selected runtime // * CSharp60Support is installed // .csproj has NO `LangVersion` // `TargetFrameworkVersion` is NOT accurate (support for C# 6 is not dependent on/trigger by .net 4.6) // Look for `CSharp60Support` or `CSharp70Support` folders // * Unity 2018.x+. LangVersion is `latest`. MSBuild 16 treats `newest` as C# 8. Re# and Rider start suggesting it. // // Actions: // * If `LangVersion` is missing or "default" // then override based on `TargetFrameworkVersion` or presence of `CSharp60Support`/`CSharp70Support` // else do nothing // * If `LangVersion` is "latest" // then override based on `CSharp80Support` presence or LangVersion matching Roslyn bundled in Unity // // Notes: // * Unity and VSTU have two separate .csproj routines. VSTU adds extra references, // the VSTU project flavour GUID and imports UnityVs.targets, which disables the // `GenerateTargetFrameworkMonikerAttribute` target // * CSharp60Support post-processes the .csproj file directly if VSTU is not installed. // If it is installed, it registers a delegate with `ProjectFilesGenerator.ProjectFileGeneration` // and removes it before it's written to disk // * `LangVersion` can be conditionally specified, which makes checking for "default" awkward // * If Unity3dRider + CSharp60Support are both installed, last write wins // Order of post-processing is non-deterministic, so Rider's LangVersion might be removed #endregion var languageLevel = ReSharperSettingsCSharpLanguageLevel.Default; if (IsLangVersionMissing(project) || IsLangVersionDefault(project)) { // Support for https://bitbucket.org/alexzzzz/unity-c-5.0-and-6.0-integration // See also https://github.com/JetBrains/resharper-unity/issues/50#issuecomment-257611218 if (project.Location.CombineWithShortName("CSharp70Support").ExistsDirectory) { languageLevel = ReSharperSettingsCSharpLanguageLevel.CSharp70; } else if (project.Location.CombineWithShortName("CSharp60Support").ExistsDirectory) { languageLevel = ReSharperSettingsCSharpLanguageLevel.CSharp60; } else { languageLevel = IsTargetFrameworkAtLeast46(project) ? ReSharperSettingsCSharpLanguageLevel.CSharp60 : ReSharperSettingsCSharpLanguageLevel.CSharp40; } } if (IsLangVersionLatest(project)) { if (project.Location.CombineWithShortName("CSharp80Support").ExistsDirectory) // https://forum.unity.com/threads/would-the-roslyn-compiler-compile-c-8-0-preview.598069/ { languageLevel = ReSharperSettingsCSharpLanguageLevel.CSharp80; } else { var appPath = myUnityProjectFileCache.GetAppPath(project); var contentPath = UnityInstallationFinder.GetApplicationContentsPath(appPath); if (!contentPath.IsNullOrEmpty()) { var roslynDir = contentPath.Combine("Tools").Combine("Roslyn"); if (roslynDir.ExistsDirectory) { languageLevel = myLanguageLevelProjectProperty.GetLatestAvailableLanguageLevel(roslynDir).ToSettingsLanguageLevel(); } } } } // Always set a value. It's either the overridden value, or Default, which resets to whatever is in the // project file SetValue(mountPoint, (CSharpLanguageProjectSettings s) => s.LanguageLevel, languageLevel); }