Skip to content

Commit

Permalink
Merge pull request #1474 from specklesystems/hotfix/gh/tracking
Browse files Browse the repository at this point in the history
fix(gh): Fixed Setup.Init call on Loader.cs + added comments
  • Loading branch information
AlanRynne authored Aug 4, 2022
2 parents ac32fad + dd34d11 commit 37ddd42
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ConnectorGrasshopper/ConnectorGrasshopper/Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ public override GH_LoadingInstruction PriorityLoad()

try
{
typeof(Setup).InvokeMember(
"Init",
BindingFlags.Static | BindingFlags.InvokeMethod,
null,
null,
new object[] { version, HostApplications.Grasshopper.Slug });
// Using reflection instead of calling `Setup.Init` to prevent loader from exploding. See comment on Catch clause.
typeof(Setup).GetMethod("Init", BindingFlags.Public | BindingFlags.Static)
.Invoke(null, new object[] { version, HostApplications.Grasshopper.Slug });
}
catch (MissingMethodException e)
catch (Exception e)
{
Console.WriteLine(e);
// This is here to ensure that other older versions of core (which did not have the Setup class) don't bork our connector initialisation.
// The only way this can happen right now is if a 3rd party plugin includes the Core dll in their distribution (which they shouldn't ever do).
// Recommended practice is to assume that our connector would be installed alongside theirs.
Log.CaptureException(e);
}

Grasshopper.Instances.DocumentServer.DocumentAdded += CanvasCreatedEvent;
Expand Down

0 comments on commit 37ddd42

Please sign in to comment.