-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(rhino): CNX-8388 handle ca1031 warnings in rhino connector #3110
fix(rhino): CNX-8388 handle ca1031 warnings in rhino connector #3110
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments so I won't forget when we do our live review @clairekuang.
Also pinged @JR-Morgan and @BovineOx in a potentially interesting one.
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/ConnectorBindingsRhino.Previews.cs
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/ConnectorBindingsRhino.Receive.cs
Outdated
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/ConnectorBindingsRhino.Receive.cs
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/ConnectorBindingsRhino.Selection.cs
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/ConnectorBindingsRhino.Selection.cs
Outdated
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs
Outdated
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave my review there as I think we are learning that we need to pool the exception experience and provide more guidance. We also need a pattern that involves a ticket for following up so we don't feel compelled to write more todos into the code :)
If TODOs are also not a warning...
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/ConnectorBindingsRhino.Previews.cs
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/ConnectorBindingsRhino.Receive.cs
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/ConnectorBindingsRhino.Receive.cs
Outdated
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/ConnectorBindingsRhino.Selection.cs
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/ConnectorBindingsRhino.Selection.cs
Outdated
Show resolved
Hide resolved
@@ -26,41 +26,44 @@ public MappingBindingsRhino() | |||
|
|||
public override MappingSelectionInfo GetSelectionInfo() | |||
{ | |||
try | |||
List<RhinoObject> selection = RhinoDoc.ActiveDoc.Objects.GetSelectedObjects(false, false)?.ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
legitimate I assume here to, that we expect each of these references to not be null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can confirm that .Objects
should never return null, but it's definitely not great to use ActiveDoc
as per rhino documentation: WARNING!! Do not use the ActiveDoc if you don't have to. Under Mac Rhino the ActiveDoc can change while a command is running. Use the doc that is passed to you in your RunCommand function or continue to use the same doc after the first call to ActiveDoc.
This it out of scope for this ticket however so I'm leaving it as is unless @AlanRynne knows if the call to ActiveDoc
would ever return null (eg when called from rhino.inside?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It certainly feels like connector/converter logic requires a context object which would contain the document in context for the current calling context... I need to play around with this in autofac so we can embody this in some DI in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ActiveDoc can and will be null when running on Rhino.Compute
, among other scenarios. But since rhino itself cannot be run headless (only grasshopper can AFAIK) this is a non-issue in the Rhino connector.
The need for a context object is real, there is contextual information that the connector needs to pass to the converter for it to do it's work properly (document, conversion caches, etc...) and some sub-conversions require different contextual information (i.e. Units.None instead of document units) to do their work properly.
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs
Outdated
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs
Outdated
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs
Outdated
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/Entry/Plugin.cs
Outdated
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/Entry/SpeckleMappingsCommandWin.cs
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs
Outdated
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs
Outdated
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies I think I added more comments only now I see them as pending 😨
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/Entry/Plugin.cs
Outdated
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/Entry/SpeckleCommandWin.cs
Outdated
Show resolved
Hide resolved
{ | ||
return new MappingSelectionInfo(new List<Schema>(), selection.Count); | ||
} | ||
catch (ArgumentNullException) { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this would fail and I would like to understand what the consequences are and have the failure recorded in the report.
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs
Outdated
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs
Outdated
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs
Outdated
Show resolved
Hide resolved
@@ -26,41 +26,44 @@ public MappingBindingsRhino() | |||
|
|||
public override MappingSelectionInfo GetSelectionInfo() | |||
{ | |||
try | |||
List<RhinoObject> selection = RhinoDoc.ActiveDoc.Objects.GetSelectedObjects(false, false)?.ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It certainly feels like connector/converter logic requires a context object which would contain the document in context for the current calling context... I need to play around with this in autofac so we can embody this in some DI in the future
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs
Outdated
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed most of the pending comments from @BovineOx except 2
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs
Outdated
Show resolved
Hide resolved
ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving after chat with Claire last night
If anything else pops up, we can deal with it in future tickets.
Description & motivation
Resolves
ca1031
exception handling warnings in the rhino connector, where easily done.Includes minor refactor and improvement for layer handling methods in
Utils
after finding bugs during testing.Adds comments for unresolved
ca1031
warnings, to be investigated further.Changes:
-Rhino connector