Skip to content

Commit e993ece

Browse files
committed
update
1 parent e34816f commit e993ece

File tree

9 files changed

+71
-32
lines changed

9 files changed

+71
-32
lines changed

src/Dynamo.All.sln

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DynamoPythonTests", "..\tes
205205
EndProject
206206
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DynamoMLDataPipeline", "DynamoMLDataPipeline\DynamoMLDataPipeline.csproj", "{5DF79F45-5F2C-41C1-BACC-890AE514CDA8}"
207207
EndProject
208-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestCodeBlockNodeSecurityIssue", "..\test\Engine\TestCodeBlockNodeSecurityIssue\TestCodeBlockNodeSecurityIssue.csproj", "{0E822F71-154F-4442-BBD6-382181A7415C}"
208+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestCodeBlockNodeSecurityIssue", "..\test\Engine\TestCodeBlockNodeSecurityIssue\TestCodeBlockNodeSecurityIssue.csproj", "{0E822F71-154F-4442-BBD6-382181A7415C}"
209+
EndProject
210+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NotificationCounter", "tools\NotificationCounter\NotificationCounter.csproj", "{569723AE-1C77-44CD-8872-8744322775BE}"
209211
EndProject
210212
Global
211213
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -536,6 +538,8 @@ Global
536538
{0E822F71-154F-4442-BBD6-382181A7415C}.Debug|Any CPU.Build.0 = Debug|Any CPU
537539
{0E822F71-154F-4442-BBD6-382181A7415C}.Release|Any CPU.ActiveCfg = Release|Any CPU
538540
{0E822F71-154F-4442-BBD6-382181A7415C}.Release|Any CPU.Build.0 = Release|Any CPU
541+
{569723AE-1C77-44CD-8872-8744322775BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
542+
{569723AE-1C77-44CD-8872-8744322775BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
539543
EndGlobalSection
540544
GlobalSection(SolutionProperties) = preSolution
541545
HideSolutionNode = FALSE
@@ -616,6 +620,7 @@ Global
616620
{C4964946-B367-44EE-9ED2-451FF2A83D32} = {5B9B5B6B-0BA7-4606-B8E5-70C958346D57}
617621
{773988FE-EDF6-45CB-A63F-482955EB3553} = {4CA0BC62-DCB3-456B-80D6-348247640BAB}
618622
{0E822F71-154F-4442-BBD6-382181A7415C} = {91C57567-DDF1-409A-880B-3A290A486AAC}
623+
{569723AE-1C77-44CD-8872-8744322775BE} = {D114C59C-CF66-4CC2-980F-9301FB4EA4E1}
619624
EndGlobalSection
620625
GlobalSection(ExtensibilityGlobals) = postSolution
621626
SolutionGuid = {89CB19C6-BF0A-4E6A-BFDA-79D143EAB59D}

src/DynamoCore/DynamoCore.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
3030
<!--The System.Drawing package is only included in DynamoCore (and not in all projects that have image resources) for simplicity-->
3131
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
32-
<PackageReference Include="Lib.Harmony" Version="2.3.3" Condition="'$(Configuration)' == 'Debug'" />
3332
</ItemGroup>
3433
<ItemGroup Label="Common dependencies">
3534
<PackageReference Include="Autodesk.IDSDK" Version="1.2.4" />

src/DynamoCore/Models/DynamoModel.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,10 +626,11 @@ public static DynamoModel Start(IStartConfiguration configuration)
626626
/// <param name="config">Start configuration</param>
627627
protected DynamoModel(IStartConfiguration config)
628628
{
629-
if (NotificationCounter.Initialize())
629+
if (DebugModes.IsEnabled("LoadNotificationCounter"))
630630
{
631-
NotificationCounter.StartCounting();
631+
NotificationCounterEntrypoint.Initialize();
632632
}
633+
633634
DynamoModel.IsCrashing = false;
634635

635636
if (config is DefaultStartConfiguration defaultStartConfig)

src/DynamoCore/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
[assembly: InternalsVisibleTo("DocumentationBrowserViewExtension")]
5757
[assembly: InternalsVisibleTo("Notifications")]
5858
[assembly: InternalsVisibleTo("NodeAutoCompleteViewExtension")]
59+
[assembly: InternalsVisibleTo("NotificationCounter")]
5960

6061
// Disable PublicAPIAnalyzer errors for this type as they're already added to the public API text file
6162
#pragma warning disable RS0016
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.IO;
3+
using System.Reflection;
4+
5+
namespace Dynamo.Utilities
6+
{
7+
internal static class NotificationCounterEntrypoint
8+
{
9+
/// <summary>
10+
/// Tries to initialize the NotificationCounter class.
11+
/// </summary>
12+
/// <returns>true if debug mode 'NotificationCounter' is turned on and if Harmony.dll was successfully loaded. Returns false otherwise</returns>
13+
internal static void Initialize()
14+
{
15+
string location = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "NotificationCounter.dll");
16+
if (!File.Exists(location))
17+
return;
18+
19+
try
20+
{
21+
var assem = Assembly.LoadFrom(location);
22+
var tp = assem.GetType("Dynamo.Utilities.NotificationCounter");
23+
var method = tp .GetMethod("StartCounting", BindingFlags.Static | BindingFlags.NonPublic);
24+
method.Invoke(null, []);
25+
}
26+
catch
27+
{
28+
}
29+
}
30+
}
31+
}

src/DynamoUtilities/DebugModes.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,13 @@ private static void RegisterDebugModes()
5454
{
5555
// Register app wide new debug modes here.
5656
AddDebugMode("DumpByteCode", "Dumps bytecode to a log file in a folder called ByteCodeLogs located in the current working dirrectory.", false);
57-
AddDebugMode("BindingNotificationCounter", "Counts binding notification events (UI wpf binding PropertyChanged, model Notifications PropertyChanged and ObservableCollection CollectionChanged)" +
58-
" at Dynamo startup and logs them periodically to a notificationCounter.log file in the current working directory", false);
57+
AddDebugMode("LoadNotificationCounter", "Loads the Notification counter assembly and initializes it. The 0Harmony.dll dependency is required.", false);
58+
AddDebugMode("EnableNotificationCounter", "Enables/Disables a notification counter for events (model Notifications PropertyChanged and ObservableCollection CollectionChanged)" +
59+
" at Dynamo startup and logs them periodically to a notification_counter.log file in the current working directory." +
60+
"The log format is NumberOfNotifications-IdentifierOfNotifierObject-NumberOfNotifierInstances" +
61+
"The log file can be deleted at any time (even while Dynamo is running)." +
62+
"Notification logs will always try to be merged/added back to existing logs in the notifications.log folder." +
63+
"Deleting the notifications.log basically allow you to do a fresh count of notifications (should wait 5 seconds after deleting to make sure no cached notifications are added)", false);
5964
AddDebugMode("CrashOnNewNodeModel", "Crash when creating a new NodeModel. Works only on Debug builds", false);
6065
}
6166

src/DynamoUtilities/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@
2929
[assembly: InternalsVisibleTo("LibraryViewExtensionWebView2")]
3030
[assembly: InternalsVisibleTo("Notifications")]
3131
[assembly: InternalsVisibleTo("SystemTestServices")]
32+
[assembly: InternalsVisibleTo("NotificationCounter")]

src/DynamoCore/Utilities/NotificationCounter.cs renamed to src/Tools/NotificationCounter/NotificationCounter.cs

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
using HarmonyLib;
2-
using System;
3-
using System.Collections.Generic;
1+
using HarmonyLib;
42
using System.Collections.ObjectModel;
53
using System.Collections.Specialized;
6-
using System.IO;
7-
using System.Linq;
84
using System.Reflection;
95
using System.Timers;
6+
using Timer = System.Timers.Timer;
107

118
namespace Dynamo.Utilities
129
{
@@ -31,25 +28,6 @@ internal static class NotificationCounter
3128
/// Tries to initialize the NotificationCounter class.
3229
/// </summary>
3330
/// <returns>true if debug mode 'NotificationCounter' is turned on and if Harmony.dll was successfully loaded. Returns false otherwise</returns>
34-
internal static bool Initialize()
35-
{
36-
if (!DebugModes.IsEnabled("BindingNotificationCounter"))
37-
return false;
38-
39-
string harmonyLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "0Harmony.dll");
40-
if (!File.Exists(harmonyLocation))
41-
return false;
42-
43-
try
44-
{
45-
return Assembly.LoadFrom(harmonyLocation) != null;
46-
}
47-
catch
48-
{
49-
return false;
50-
}
51-
}
52-
5331
internal static void StartCounting()
5432
{
5533
try
@@ -68,7 +46,7 @@ internal static void StartCounting()
6846
timer.Interval = timerInterval;
6947
timer.Start();
7048

71-
harmonyIntance = new Harmony("BindingNotificationCounter");
49+
harmonyIntance = new Harmony("NotificationCounter");
7250

7351
AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler((object sender, AssemblyLoadEventArgs args) => PatchFromAssmebly(args.LoadedAssembly));
7452

@@ -161,7 +139,7 @@ private static void PatchFromAssmebly(Assembly assembly)
161139

162140
private static void Log(object sender, string property)
163141
{
164-
if (!DebugModes.IsEnabled("BindingNotificationCounter"))
142+
if (!DebugModes.IsEnabled("EnableNotificationCounter"))
165143
return;
166144

167145
try
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<ImportGroup Label="PropertySheets">
3+
<Import Project="$(SolutionDir)Config\CS_SDK.props" />
4+
</ImportGroup>
5+
<PropertyGroup>
6+
<TargetFramework>net8.0</TargetFramework>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Lib.Harmony" Version="2.3.3" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<ProjectReference Include="..\..\DynamoUtilities\DynamoUtilities.csproj" />
17+
</ItemGroup>
18+
</Project>

0 commit comments

Comments
 (0)