Skip to content

Commit

Permalink
Merge pull request #598 from mcneel/AndyPayne/Rhino8Compat2
Browse files Browse the repository at this point in the history
Andy payne/rhino8 compat2
  • Loading branch information
andyopayne committed Aug 23, 2023
2 parents 63b3c85 + 2cb1ce2 commit 7f73ab6
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/workflow_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
echo ${{ steps.revision.outputs.revision }}
(get-content .\src\compute.geometry\FixedEndpoints.cs).replace('git_sha = null', 'git_sha = "${{ steps.revision.outputs.revision }}"') | set-content .\src\compute.geometry\FixedEndpoints.cs
- name: build
run: dotnet publish src/compute.sln -c Release -p:PublishTrimmed=true --self-contained true -r win-x64
run: dotnet publish src/hops.sln -c Release
- name: artifacts
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
uses: actions/upload-artifact@v2
Expand Down
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@
},
"cwd": "${workspaceFolder}",
"console": "internalConsole"
},
{
"name": "Launch compute.geometry",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "Build",
"program": "${workspaceFolder}/src/bin/Debug/compute.geometry/compute.geometry.exe",
"targetArchitecture": "x86_64",
"justMyCode": false,
"args": [],
"cwd": "${workspaceFolder}",
"console": "internalConsole"
}
],
"compounds": []
Expand Down
24 changes: 24 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,30 @@
"clear": true
},
"group": "build"
},
{
"label": "Build",
"command": "dotnet build ${workspaceFolder}/src/Hops.sln",
"type": "shell",
"args": [],
"problemMatcher": "$msCompile",
"presentation": {
"reveal": "always",
"clear": true
},
"group": "build"
},
{
"label": "Publish",
"command": "dotnet publish ${workspaceFolder}/src/Hops.sln -c Release",
"type": "shell",
"args": [],
"problemMatcher": "$msCompile",
"presentation": {
"reveal": "always",
"clear": true
},
"group": "build"
}
]
}
2 changes: 2 additions & 0 deletions src/compute.geometry/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public static void Load()

#if DEBUG
Debug = true;
#elif RELEASE
Debug = false;
#endif
Debug = GetEnvironmentVariable(RHINO_COMPUTE_DEBUG, Debug);

Expand Down
11 changes: 6 additions & 5 deletions src/compute.geometry/DataCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using GH_IO.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Serilog;

namespace compute.geometry
{
Expand Down Expand Up @@ -90,7 +91,7 @@ static void CGCacheDirectory()
}
catch(Exception ex)
{
Serilog.Log.Error(ex, "exception while GC on cache directory");
Log.Error(ex, "exception while GC on cache directory");
}
}

Expand Down Expand Up @@ -121,8 +122,8 @@ public static GrasshopperDefinition GetCachedDefinition(string key)
}
catch(Exception ex)
{
Serilog.Log.Error($"Unable to read cache file: {filename}");
Serilog.Log.Error(ex, "File error exception");
Log.Error($"Unable to read cache file: {filename}");
Log.Error(ex, "File error exception");
}
}
return null;
Expand Down Expand Up @@ -162,8 +163,8 @@ public static void SetCachedDefinition(string key, GrasshopperDefinition definit
}
catch(Exception ex)
{
Serilog.Log.Error($"Unable to write cache file: {filename}");
Serilog.Log.Error(ex, "File error exception");
Log.Error($"Unable to write cache file: {filename}");
Log.Error(ex, "File error exception");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/compute.geometry/GrasshopperDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ private static void Fsw_Changed(object sender, FileSystemEventArgs e)
_watchedFileRuntimeSerialNumber++;
}

static void LogDebug(string message) { Serilog.Log.Debug(message); }
static void LogError(string message) { Serilog.Log.Error(message); }
static void LogDebug(string message) { Log.Debug(message); }
static void LogError(string message) { Log.Error(message); }

public static GrasshopperDefinition FromUrl(string url, bool cache)
{
Expand Down
1 change: 0 additions & 1 deletion src/compute.geometry/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public static void Init()
var logger = new LoggerConfiguration()
.MinimumLevel.Is(level)
.MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
.Filter.ByExcluding("RequestPath in ['/healthcheck', '/favicon.ico']")
.Enrich.FromLogContext()
.WriteTo.Console(outputTemplate: "CG {Port} [{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}")
.WriteTo.File(new JsonFormatter(renderMessage: true), path, rollingInterval: RollingInterval.Day, retainedFileCountLimit: limit);
Expand Down
5 changes: 3 additions & 2 deletions src/compute.geometry/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ static void Main(string[] args)
RhinoInside.Resolver.LoadRhino();

var host = Host.CreateDefaultBuilder(args)
.UseSerilog()
.ConfigureWebHostDefaults(webBuilder =>
{
var b = webBuilder.ConfigureKestrel((context, options) =>
Expand All @@ -63,7 +62,9 @@ static void Main(string[] args)
// ComputeChildren.ParentPort = port;
//}
}).Build();
})
.UseSerilog(Log.Logger)
.Build();
Shutdown.StartTimer(host);
host.Run();

Expand Down
10 changes: 2 additions & 8 deletions src/compute.geometry/Resolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Loader;
using compute.geometry;
using Serilog;

namespace RhinoInside
{
Expand All @@ -20,14 +22,6 @@ public static void Initialize()
if (System.IntPtr.Size != 8)
throw new Exception("Only 64 bit applications can use RhinoInside");
AppDomain.CurrentDomain.AssemblyResolve += ResolveForRhinoAssemblies;

// Force load WindowsBase from the WindowsDesktop set of assemblies
var path = typeof(int).Assembly.Location;
string directory =Path.GetDirectoryName(path);
int index = directory.IndexOf("NETCORE", StringComparison.OrdinalIgnoreCase);
directory = directory.Substring(0, index) + "WindowsDesktop" + directory.Substring(index + "NETCORE".Length);
string windowsBase = Path.Combine(directory, "WindowsBase.dll");
Assembly.LoadFrom(windowsBase);
}

static string _rhinoSystemDirectory;
Expand Down
2 changes: 1 addition & 1 deletion src/compute.geometry/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using Carter;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
Expand Down Expand Up @@ -28,7 +29,6 @@ public void Configure(IApplicationBuilder app)
{
RhinoCoreStartup();

app.UseSerilogRequestLogging();
app.UseRouting();
app.UseCors();
//if (!String.IsNullOrEmpty(Config.ApiKey))
Expand Down
28 changes: 20 additions & 8 deletions src/compute.geometry/compute.geometry.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net7.0-windows</TargetFramework>
<AssemblyName>compute.geometry</AssemblyName>
<OutputType>Exe</OutputType>
<Platforms>x64</Platforms>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<RuntimeFrameworkVersion>7.0.0</RuntimeFrameworkVersion>
<RollForward>LatestMinor</RollForward>
<UseWpf>True</UseWpf>
<UseWindowsForms>True</UseWindowsForms>
<SelfContained>False</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<AppendTargetFrameworkToOutputPath>False</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>False</AppendRuntimeIdentifierToOutputPath>
<EnableWindowsTargeting>True</EnableWindowsTargeting>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<OutputPath>..\bin\Debug\$(AssemblyName)</OutputPath>
Expand All @@ -13,18 +21,22 @@
<OutputPath>..\bin\Release\$(AssemblyName)</OutputPath>
<PublishDir>..\dist\$(AssemblyName)</PublishDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Optimize>True</Optimize>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Carter" Version="7.0.0" />
<PackageReference Include="Grasshopper" Version="8.0.23031.14305-wip" />
<PackageReference Include="Grasshopper" Version="8.0.23031.14305-wip" ExcludeAssets="runtime"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="RhinoCommon" Version="8.0.23031.14305-wip" />
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="RhinoCommon" Version="8.0.23031.14305-wip" ExcludeAssets="runtime"/>
<PackageReference Include="Serilog" Version="3.0.2-dev-02044" />
<PackageReference Include="Serilog.AspNetCore" Version="6.1.0" />
<PackageReference Include="Serilog.Expressions" Version="3.4.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="System.Management" Version="7.0.0" />
<PackageReference Include="System.Runtime.Caching" Version="7.0.0" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.0" />
</ItemGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion src/hops/RemoteDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public void GetRemoteDescription()

if (svg != null)
{
var method = typeof(Rhino.UI.DrawingUtilities).GetMethod("BitmapFromSvg");
var method = typeof(Rhino.UI.DrawingUtilities).GetMethod("BitmapFromSvg", new[] {typeof(string), typeof(int), typeof(int)} );
if (method != null)
{
_customIcon = method.Invoke(null, new object[] { svg, 24, 24 }) as System.Drawing.Bitmap;
Expand Down
11 changes: 8 additions & 3 deletions src/rhino.compute/rhino.compute.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
<TargetFramework>net7.0</TargetFramework>
<AssemblyName>rhino.compute</AssemblyName>
<OutputType>Exe</OutputType>
<Platforms>x64</Platforms>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<RuntimeFrameworkVersion>7.0.0</RuntimeFrameworkVersion>
<RollForward>LatestMinor</RollForward>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ApplicationIcon>favicon.ico</ApplicationIcon>
<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
<SelfContained>True</SelfContained>
<PublishTrimmed>False</PublishTrimmed>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<OutputPath>..\bin\Debug\$(AssemblyName)</OutputPath>
<DefineConstants>TRACE;RHINO_COMPUTE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<OutputPath>..\bin\Release\$(AssemblyName)</OutputPath>
<DefineConstants>TRACE;RHINO_COMPUTE</DefineConstants>
<PublishDir>..\dist\$(AssemblyName)</PublishDir>
Expand Down

0 comments on commit 7f73ab6

Please sign in to comment.