Skip to content

Commit

Permalink
stabilize tests and update libg (#15736)
Browse files Browse the repository at this point in the history
  • Loading branch information
pinzart90 authored Jan 16, 2025
1 parent 18e1249 commit 0b11829
Show file tree
Hide file tree
Showing 24 changed files with 161 additions and 141 deletions.
6 changes: 3 additions & 3 deletions src/DynamoCore/DynamoCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
<ItemGroup Label="Common dependencies">
<PackageReference Include="Autodesk.IDSDK" Version="1.2.4" />
<PackageReference Include="Greg" Version="3.0.2.6533" />
<PackageReference Include="DynamoVisualProgramming.LibG_230_0_0" Version="3.0.0.6876" GeneratePathProperty="true" ExcludeAssets="all"/>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3231" Condition=" '$(Configuration)' == 'Release' " GeneratePathProperty="true" ExcludeAssets="runtime"/>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0_debug" Version="3.4.0.3231" Condition=" '$(Configuration)' == 'Debug' " GeneratePathProperty="true" ExcludeAssets="runtime"/>
<PackageReference Include="DynamoVisualProgramming.LibG_230_0_0" Version="3.0.0.7226" GeneratePathProperty="true" ExcludeAssets="all"/>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3546" Condition=" '$(Configuration)' == 'Release' " GeneratePathProperty="true" ExcludeAssets="runtime"/>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0_debug" Version="3.4.0.3546" Condition=" '$(Configuration)' == 'Debug' " GeneratePathProperty="true" ExcludeAssets="runtime"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" CopyXML="true" />
<PackageReference Include="RestSharp" Version="112.0.0" CopyXML="true" />
<PackageReference Include="Lucene.Net" Version="4.8.0-beta00016" />
Expand Down
14 changes: 10 additions & 4 deletions src/DynamoCore/Logging/DynamoAnalyticsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public void TrackEvent(Actions action, Categories category, string description,
{
serviceInitialized.Wait();

lock(trackEventLockObj)
lock (trackEventLockObj)
{
if (!ReportingAnalytics) return;

Expand Down Expand Up @@ -403,7 +403,7 @@ public void EndEventTask(Task<IDisposable> taskToEnd)

Task.Run(() =>
{
lock(trackEventLockObj)
lock (trackEventLockObj)
{
taskToEnd.Wait();
taskToEnd.Result.Dispose();
Expand All @@ -417,7 +417,7 @@ public IDisposable TrackFileOperationEvent(string filepath, Actions operation, i
serviceInitialized.Wait();
if (!ReportingAnalytics) return Disposable;

lock(trackEventLockObj)
lock (trackEventLockObj)
{
var e = new FileOperationEvent()
{
Expand Down Expand Up @@ -469,7 +469,13 @@ public void Dispose()
// If the Analytics Client was initialized, shut it down.
// Otherwise skip this step because it would cause an exception.
if (Service.IsInitialized)
Service.ShutDown();
{
// Lock shutdown sequence in case other tracking calls might be executing concurently.
lock (trackEventLockObj)
{
Service.ShutDown();
}
}

if (Session != null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
<PackageReference Include="HelixToolkit.Core.Wpf" Version="2.24.0" />
<PackageReference Include="HelixToolkit.SharpDX.Core.Wpf" Version="2.24.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3231"/>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3546"/>
<PackageReference Include="FontAwesome5" Version="2.1.11" />
<PackageReference Include="AvalonEdit" Version="6.3.0.90" CopyXML="true" />
<PackageReference Include="Greg" Version="3.0.2.6533" />
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoManipulation/DynamoManipulation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3231" />
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3546" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/Analysis/Analysis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<None Remove="AnalysisImages.resources" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3231"/>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3546"/>
<ProjectReference Include="..\..\DynamoCore\DynamoCore.csproj">
<Project>{7858fa8c-475f-4b8e-b468-1f8200778cf8}</Project>
<Name>DynamoCore</Name>
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/CoreNodes/CoreNodes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<Compile Remove="GeometryColor.cs" />
</ItemGroup>
<ItemGroup Label="Common dependencies">
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3231"/>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3546"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\DynamoCore\DynamoCore.csproj">
Expand Down
38 changes: 28 additions & 10 deletions src/Libraries/DSOfficeUtilities/Excel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static bool ExcelProcessRunning
{
get
{
return Process.GetProcessesByName("EXCEL").Length != 0;
return GetExcelProcess(_app) != null;
}
}

Expand All @@ -123,21 +123,39 @@ public static bool HasValidExcelReference
/// </summary>
private static void TryQuitAndCleanup(bool saveWorkbooks)
{
if (HasValidExcelReference)
try
{
if (ExcelProcessRunning)
if (HasValidExcelReference)
{
App.Workbooks.Cast<Workbook>().ToList().ForEach((wb) => wb.Close(saveWorkbooks));
App.Quit();
}
if (ExcelProcessRunning)
{
App.Workbooks.Cast<Workbook>().ToList().ForEach((wb) => wb.Close(saveWorkbooks));
App.Quit();
}

while (Marshal.ReleaseComObject(_app) > 0)
{
while (Marshal.ReleaseComObject(_app) > 0)
{

}
}

_app = null;
GetExcelProcess(App).Kill();
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
_app = null;
}

[DllImport("user32.dll")]
static extern int GetWindowThreadProcessId(int hWnd, out int lpdwProcessId);

internal static Process GetExcelProcess(Application excelApp)
{
int id;
GetWindowThreadProcessId(excelApp.Hwnd, out id);
return Process.GetProcessById(id);
}

internal static void OnProcessExit(object sender, EventArgs eventArgs)
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/GeometryColor/GeometryColor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<NoWarn>MSB3539;CS1591;NUnit2005;NUnit2007;CS0618;CS0612;CS0672</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3231"/>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3546"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\DynamoCore\DynamoCore.csproj">
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/GeometryUI/GeometryUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</ReferenceCopyLocalPaths>
</ItemDefinitionGroup>
<ItemGroup>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3231"/>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3546"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/GeometryUIWpf/GeometryUIWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ReferenceCopyLocalPaths>
</ItemDefinitionGroup>
<ItemGroup>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3231"/>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3546"/>
</ItemGroup>
<ItemGroup>
<Page Include="Controls\ExportWithUnitsControl.xaml">
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/Tesellation/Tessellation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<NoWarn>MSB3539;CS1591;NUnit2005;NUnit2007;CS0618;CS0612;CS0672</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3231"/>
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3546"/>
<PackageReference Include="MIConvexHull" version="1.1.17.411" CopyPDB="true" />
<PackageReference Include="StarMath" version="2.0.17.1019" CopyPDB="true" />
<PackageReference Include="System.Resources.Extensions" Version="5.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="Greg" Version="3.0.2.6533" />
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3231"/>
<PackageReference Include="DynamoVisualProgramming.LibG_230_0_0" Version="3.0.0.6876" />
<PackageReference Include="DynamoVisualProgramming.LibG_231_0_0" Version="3.4.0.3546"/>
<PackageReference Include="Magick.NET.Core" Version="7.0.1" />
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="7.24.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
Expand Down
21 changes: 6 additions & 15 deletions test/DynamoCoreTests/DynamoCoreTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Diagnostics.Runtime" Version="2.0.226801" GeneratePathProperty="true" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\DynamoCore\DynamoCore.csproj">
Expand Down Expand Up @@ -139,18 +138,10 @@
<ItemGroup>
<Folder Include="NodesJsonDatasets\" />
</ItemGroup>
<Target Name="CopyDisableADPTestDeps">
<!--ms diag runtime + deps -->
<Message Importance="High" Text="copying disable adp test deps to test dependencies folder" />
<Copy SourceFiles="$(PkgMicrosoft_Diagnostics_Runtime)\lib\netstandard2.0\Microsoft.Diagnostics.Runtime.dll" DestinationFolder="$(TestDependenciesPath)" />
</Target>

<Target Name="MoveSomeTestDepsOutOfBin" AfterTargets="Build">
<Message Importance="High" Text="copying test dependencies to test dependencies folder" />
<CallTarget Targets="CopyDisableADPTestDeps"></CallTarget>
<!--moq + deps-->
<Copy SourceFiles="$(PkgCastle_Core)\lib\netstandard2.0\Castle.Core.dll" DestinationFolder="$(TestDependenciesPath)" />
<Copy SourceFiles="$(PkgMoq)\lib\netstandard2.0\Moq.dll" DestinationFolder="$(TestDependenciesPath)" />
<Copy SourceFiles="$(PkgMoq)\lib\netstandard2.0\Moq.dll" DestinationFolder="$(OutputPath)" />
</Target>
<Target Name="MoveSomeTestDepsOutOfBin" AfterTargets="Build">
<!--moq + deps-->
<Copy SourceFiles="$(PkgCastle_Core)\lib\netstandard2.0\Castle.Core.dll" DestinationFolder="$(TestDependenciesPath)" />
<Copy SourceFiles="$(PkgMoq)\lib\netstandard2.0\Moq.dll" DestinationFolder="$(TestDependenciesPath)" />
<Copy SourceFiles="$(PkgMoq)\lib\netstandard2.0\Moq.dll" DestinationFolder="$(OutputPath)" />
</Target>
</Project>
65 changes: 22 additions & 43 deletions test/DynamoCoreTests/Logging/AnalyticsServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.Diagnostics.Runtime;
using NUnit.Framework;
using System.Runtime.Versioning;

namespace Dynamo.Tests.Loggings
{
Expand Down Expand Up @@ -41,43 +38,32 @@ public void DisableAnalytics()
{
DynamoShapeManager.Utilities.GetInstalledAsmVersion2(versions, ref locatedPath, coreDirectory);
}

try
{
Assert.DoesNotThrow(() =>
{
dynamoCLI = Process.Start(new ProcessStartInfo(Path.Combine(coreDirectory, "DynamoCLI.exe"), $"--GeometryPath \"{locatedPath}\" -k --DisableAnalytics -o \"{openPath}\" ") { UseShellExecute = true });

dynamoCLI = Process.Start(new ProcessStartInfo(Path.Combine(coreDirectory, "DynamoCLI.exe"), $"--GeometryPath \"{locatedPath}\" -k --DisableAnalytics -o \"{openPath}\" ") { UseShellExecute = true });

Thread.Sleep(5000);// Wait 5 seconds to open the dyn
Assert.IsFalse(dynamoCLI.HasExited);
var dt = DataTarget.AttachToProcess(dynamoCLI.Id, false);
var assemblies = dt
.ClrVersions
.Select(dtClrVersion => dtClrVersion.CreateRuntime())
.SelectMany(runtime => runtime.AppDomains.SelectMany(runtimeAppDomain => runtimeAppDomain.Modules))
.Select(clrModule => clrModule.AssemblyName)
.Distinct()
.Where(x => x != null)
.ToList();
Thread.Sleep(5000);// Wait 5 seconds to open the dyn
Assert.IsFalse(dynamoCLI.HasExited);

var firstASMmodulePath = string.Empty;
foreach (string module in assemblies)
var firstASMmodulePath = string.Empty;
foreach (ProcessModule module in dynamoCLI.Modules)
{
if (module.ModuleName.IndexOf("Analytics.dll", StringComparison.OrdinalIgnoreCase) != -1)
{
if (module.IndexOf("Analytics", StringComparison.OrdinalIgnoreCase) != -1)
{
Assert.Fail("Analytics module was loaded");
}
if (module.IndexOf("AdpSDKCSharpWrapper", StringComparison.OrdinalIgnoreCase) != -1)
{
Assert.Fail("ADP module was loaded");
}
Assert.Fail("Analytics module was loaded");
}
});
if (module.ModuleName.IndexOf("AdpSDKCSharpWrapper.dll", StringComparison.OrdinalIgnoreCase) != -1)
{
Assert.Fail("ADP module was loaded");
}
module.Dispose();
}
}
finally
{

dynamoCLI?.Kill();
dynamoCLI?.Dispose();
}
}

Expand Down Expand Up @@ -116,35 +102,28 @@ public void DisableAnalyticsViaNoNetWorkMode()
dynamoCLI = Process.Start(new ProcessStartInfo(Path.Combine(coreDirectory, "DynamoCLI.exe"), $"--GeometryPath \"{locatedPath}\" -k --NoNetworkMode -o \"{openPath}\" ") { UseShellExecute = true });

Thread.Sleep(5000);// Wait 5 seconds to open the dyn

Assert.IsFalse(dynamoCLI.HasExited);
var dt = DataTarget.AttachToProcess(dynamoCLI.Id, false);
var assemblies = dt
.ClrVersions
.Select(dtClrVersion => dtClrVersion.CreateRuntime())
.SelectMany(runtime => runtime.AppDomains.SelectMany(runtimeAppDomain => runtimeAppDomain.Modules))
.Select(clrModule => clrModule.AssemblyName)
.Distinct()
.Where(x => x != null)
.ToList();

var firstASMmodulePath = string.Empty;
foreach (string module in assemblies)
foreach (ProcessModule module in dynamoCLI.Modules)
{
if (module.IndexOf("Analytics", StringComparison.OrdinalIgnoreCase) != -1)
if (module.ModuleName.IndexOf("Analytics.dll", StringComparison.OrdinalIgnoreCase) != -1)
{
Assert.Fail("Analytics module was loaded");
}
if (module.IndexOf("AdpSDKCSharpWrapper", StringComparison.OrdinalIgnoreCase) != -1)
if (module.ModuleName.IndexOf("AdpSDKCSharpWrapper.dll", StringComparison.OrdinalIgnoreCase) != -1)
{
Assert.Fail("ADP module was loaded");
}
module.Dispose();
}
});
}
finally
{

dynamoCLI?.Kill();
dynamoCLI?.Dispose();
}
}
}
Expand Down
Loading

0 comments on commit 0b11829

Please sign in to comment.