Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
Browse files Browse the repository at this point in the history
  • Loading branch information
zeusongit committed Dec 6, 2023
2 parents cd1c4f9 + c599f9f commit 0cae237
Show file tree
Hide file tree
Showing 77 changed files with 829 additions and 2,811 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_dynamo_all_net6.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
path: Dynamo
repository: DynamoDS/Dynamo
- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
- name: Disable problem matcher
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_dynamo_all_net8.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
path: Dynamo
repository: DynamoDS/Dynamo
- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Disable problem matcher
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
path: Dynamo
repository: DynamoDS/Dynamo
- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
# Initializes the CodeQL tools for scanning.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dynamoBinDiff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
path: net60_Win_Dynamo
repository: DynamoDS/Dynamo
- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
- name: Disable problem matcher
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
path: master_net60_Win_Dynamo
repository: DynamoDS/Dynamo
- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
- name: Disable problem matcher
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dynamoNet6.0_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
path: Dynamo
repository: DynamoDS/Dynamo
- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
- name: Disable problem matcher
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dynamoNet6.0_linux_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
with:
path: Dynamo
- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
- name: Disable problem matcher
run: echo "::remove-matcher owner=csc::"

Expand Down
4 changes: 2 additions & 2 deletions src/Config/CS_SDK.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PlatformTarget >x64</PlatformTarget>
<!--Use the property DotNet to set TargetFramework from commandline without forcing it on all projects-->
<!--Ex. DynamoServices uses TargetFramework netstandard2.0 -->
<DotNet>net6.0</DotNet>
<DotNet>net8.0</DotNet>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">16.0</VisualStudioVersion>
<TargetFramework>$(DotNet)</TargetFramework>
<FileAlignment>512</FileAlignment>
Expand Down Expand Up @@ -146,4 +146,4 @@
</PropertyGroup>
</Otherwise>
</Choose>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Windows.Controls;
using Dynamo.Logging;
using Dynamo.Utilities;
using DynamoUtilities;
using Microsoft.Web.WebView2.Core;
using Microsoft.Web.WebView2.Wpf;

Expand All @@ -21,7 +22,7 @@ public partial class DocumentationBrowserView : UserControl, IDisposable
private readonly DocumentationBrowserViewModel viewModel;
private const string VIRTUAL_FOLDER_MAPPING = "appassets";
static readonly string HTML_IMAGE_PATH_PREFIX = @"http://";
private bool hasBeenInitialized;
internal AsyncMethodState initState = AsyncMethodState.NotStarted;
private ScriptingObject comScriptingObject;
private string fontStylePath = "Dynamo.Wpf.Views.GuidedTour.HtmlPages.Resources.ArtifaktElement-Regular.woff";

Expand Down Expand Up @@ -104,26 +105,22 @@ private void ShouldAllowNavigation(object sender, CoreWebView2NavigationStarting
/// <param name="link"></param>
public void NavigateToPage(Uri link)
{
InitializeAsync();
Dispatcher.Invoke(InitializeAsync);
}

protected virtual void Dispose(bool disposing)
{
// Cleanup
this.viewModel.LinkChanged -= NavigateToPage;
this.documentationBrowser.NavigationStarting -= ShouldAllowNavigation;
this.documentationBrowser.DpiChanged -= DocumentationBrowser_DpiChanged;

if (this.documentationBrowser.CoreWebView2 != null)
if (this.documentationBrowser != null)
{
this.documentationBrowser.CoreWebView2.WebMessageReceived -= CoreWebView2OnWebMessageReceived;
}
this.documentationBrowser.NavigationStarting -= ShouldAllowNavigation;
this.documentationBrowser.DpiChanged -= DocumentationBrowser_DpiChanged;
if (this.documentationBrowser.CoreWebView2 != null)
{
this.documentationBrowser.CoreWebView2.WebMessageReceived -= CoreWebView2OnWebMessageReceived;
}

// Note to test writers
// Disposing the document browser will cause future tests
// that uses the Browser component to crash
if (!Models.DynamoModel.IsTestMode)
{
this.documentationBrowser.Dispose();
}
}
Expand Down Expand Up @@ -159,8 +156,9 @@ async void InitializeAsync()
}

// Only initialize once
if (!hasBeenInitialized)
if (initState == AsyncMethodState.NotStarted)
{
initState = AsyncMethodState.Started;
if (!string.IsNullOrEmpty(WebBrowserUserDataFolder))
{
//This indicates in which location will be created the WebView2 cache folder
Expand All @@ -169,9 +167,9 @@ async void InitializeAsync()
UserDataFolder = WebBrowserUserDataFolder
};
}

//Initialize the CoreWebView2 component otherwise we can't navigate to a web page
await documentationBrowser.EnsureCoreWebView2Async();


this.documentationBrowser.CoreWebView2.WebMessageReceived += CoreWebView2OnWebMessageReceived;
comScriptingObject = new ScriptingObject(this.viewModel);
Expand All @@ -181,7 +179,7 @@ async void InitializeAsync()
this.documentationBrowser.CoreWebView2.Settings.IsZoomControlEnabled = true;
this.documentationBrowser.CoreWebView2.Settings.AreDevToolsEnabled = true;

hasBeenInitialized = true;
initState = AsyncMethodState.Done;
}

if(Directory.Exists(VirtualFolderPath))
Expand All @@ -192,10 +190,7 @@ async void InitializeAsync()

htmlContent = ResourceUtilities.LoadResourceAndReplaceByKey(htmlContent, "#fontStyle", fontStylePath);

Dispatcher.BeginInvoke(new Action(() =>
{
this.documentationBrowser.NavigateToString(htmlContent);
}));
this.documentationBrowser.NavigateToString(htmlContent);
}

private void CoreWebView2OnWebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs e)
Expand All @@ -209,6 +204,11 @@ private void CoreWebView2OnWebMessageReceived(object sender, CoreWebView2WebMess
/// </summary>
public void Dispose()
{
if (initState == AsyncMethodState.Started)
{
Log("DocumentationBrowserView is being disposed but async initialization is still not done");
}

Dispose(true);
GC.SuppressFinalize(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public override void Loaded(ViewLoadedParams viewLoadedParams)

public override void Shutdown()
{
Dispose();
// Do nothing for now
}

private void OnInsertFile(object sender, InsertDocumentationLinkEventArgs e)
Expand Down
38 changes: 37 additions & 1 deletion src/DynamoApplications/PathResolvers.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Dynamo.Interfaces;

namespace Dynamo.Applications
Expand Down Expand Up @@ -58,13 +60,41 @@ public IEnumerable<string> PreloadedLibraryPaths

public string UserDataRootFolder
{
get { return string.Empty; }
get { return Path.Combine(Environment.GetFolderPath(
Environment.SpecialFolder.ApplicationData),
"Dynamo", "Dynamo Core").ToString(); }
}

public string CommonDataRootFolder
{
get { return string.Empty; }
}

/// <summary>
/// Returns the full path of user data location of all version of this
/// Dynamo product installed on this system. The default implementation
/// returns list of all subfolders in %appdata%\Dynamo as well as
/// %appdata%\Dynamo\Dynamo Core\ folders.
/// </summary>
/// <returns></returns>
public IEnumerable<string> GetDynamoUserDataLocations()
{
var appDatafolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
var dynamoFolder = Path.Combine(appDatafolder, "Dynamo");
if (!Directory.Exists(dynamoFolder)) return Enumerable.Empty<string>();

var paths = new List<string>();
var coreFolder = new FileInfo(UserDataRootFolder).FullName;
//Dynamo Core folder has to be enumerated first to cater migration from
//Dynamo 1.0 to Dynamo Core 1.0
if (Directory.Exists(coreFolder))
{
paths.AddRange(Directory.EnumerateDirectories(coreFolder));
}

paths.AddRange(Directory.EnumerateDirectories(dynamoFolder));
return paths;
}
}

internal class CLIPathResolver : IPathResolver
Expand Down Expand Up @@ -125,5 +155,11 @@ public IEnumerable<string> PreloadedLibraryPaths
public string UserDataRootFolder { get; private set; }

public string CommonDataRootFolder { get; private set; }

public IEnumerable<string> GetDynamoUserDataLocations()
{
// Do nothing for now.
return Enumerable.Empty<string>();
}
}
}
59 changes: 0 additions & 59 deletions src/DynamoApplications/StartupUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,48 +75,6 @@ public static class StartupUtils
/// </summary>
public static event Action<string> ASMPreloadFailure;

#if NET6_0_OR_GREATER
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
#endif
internal class SandboxLookUp : DynamoLookUp
{
public override IEnumerable<string> GetDynamoInstallLocations()
{
const string regKey64 = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\";
//Open HKLM for 64bit registry
var regKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
//Open Windows/CurrentVersion/Uninstall registry key
regKey = regKey.OpenSubKey(regKey64);

//Get "InstallLocation" value as string for all the subkey that starts with "Dynamo"
return regKey.GetSubKeyNames().Where(s => s.StartsWith("Dynamo")).Select(
(s) => regKey.OpenSubKey(s).GetValue("InstallLocation") as string);
}
}

/// <summary>
///this class is left unimplemented,unclear how to
///lookup installation locations on nix/mac
/// </summary>
internal class CLILookUp : DynamoLookUp
{
public override IEnumerable<string> GetDynamoInstallLocations()
{
throw new NotImplementedException();
int p = (int)Environment.OSVersion.Platform;
if ((p == 4) || (p == 6) || (p == 128))
{
Console.WriteLine("Running on Unix");
}
else
{
Console.WriteLine("NOT running on Unix");
}

return null;
}
}

public struct CommandLineArguments
{
public static CommandLineArguments Parse(string[] args)
Expand Down Expand Up @@ -211,22 +169,6 @@ public static void PreloadShapeManager(ref string geometryFactoryPath, ref strin
preloaderLocation = preloader.PreloaderLocation;
}

/// <summary>
///if we are building a model for CLI mode, then we don't want to start an updateManager
///for now, building an updatemanager instance requires finding Dynamo install location
///which if we are running on mac os or *nix will use different logic then SandboxLookup
/// </summary>
#if NET6_0_OR_GREATER
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
#endif
private static IUpdateManager InitializeUpdateManager()
{
var cfg = UpdateManagerConfiguration.GetSettings(new SandboxLookUp());
var um = new Dynamo.Updates.UpdateManager(cfg);
Debug.Assert(cfg.DynamoLookUp != null);
return um;
}

/// <summary>
/// Use this overload to construct a DynamoModel in CLI context when the location of ASM to use is known, host analytics info is known and you want to set data paths.
/// </summary>
Expand Down Expand Up @@ -391,7 +333,6 @@ private static DynamoModel StartDynamoWithDefaultConfig(bool CLImode,
HostAnalyticsInfo = info,
CLIMode = CLImode,
AuthProvider = CLImode || noNetworkMode ? null : new Core.IDSDKManager(),
UpdateManager = CLImode ? null : OSHelper.IsWindows() ? InitializeUpdateManager() : null,
StartInTestMode = CLImode,
PathResolver = CreatePathResolver(CLImode, preloaderLocation, userDataFolder, commonDataFolder),
IsServiceMode = isServiceMode,
Expand Down
15 changes: 15 additions & 0 deletions src/DynamoCore/Configuration/IPathResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ public interface IPathResolver
/// as it will be appended by PathManager.
/// </summary>
string CommonDataRootFolder { get; }

/// <summary>
/// Returns a list of user data folders on this system.
/// </summary>
/// <returns>
/// The implementation of this interface method should return a list of user
/// data folders, one for each of Dynamo product installed on the system. When
/// there is no Dynamo product installed, this method returns an empty list.
/// </returns>
IEnumerable<string> GetDynamoUserDataLocations();
}

/// <summary>
Expand Down Expand Up @@ -189,6 +199,11 @@ public interface IPathManager
/// </summary>
int MinorFileVersion { get; }

/// <summary>
/// Integration specific PathResolver
/// </summary>
IPathResolver PathResolver { get; }

/// <summary>
/// Call this method to add additional path for consideration when path
/// resolution take place.
Expand Down
Loading

0 comments on commit 0cae237

Please sign in to comment.