Skip to content
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

Merged
merged 20 commits into from
Jan 9, 2024

Conversation

clairekuang
Copy link
Member

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

Copy link
Member

@AlanRynne AlanRynne left a 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.

Copy link
Contributor

@BovineOx BovineOx left a 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...

@@ -26,41 +26,44 @@ public MappingBindingsRhino()

public override MappingSelectionInfo GetSelectionInfo()
{
try
List<RhinoObject> selection = RhinoDoc.ActiveDoc.Objects.GetSelectedObjects(false, false)?.ToList();
Copy link
Contributor

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?

Copy link
Member Author

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?)

Copy link
Contributor

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

Copy link
Member

@AlanRynne AlanRynne Jan 8, 2024

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.

@AlanRynne AlanRynne changed the title fix(rhino): Cnx 8388 handle ca1031 warnings in rhino connector fix(rhino): CNX-8388 handle ca1031 warnings in rhino connector Dec 19, 2023
Copy link
Contributor

@BovineOx BovineOx left a 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 😨

{
return new MappingSelectionInfo(new List<Schema>(), selection.Count);
}
catch (ArgumentNullException) { }
Copy link
Contributor

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.

@@ -26,41 +26,44 @@ public MappingBindingsRhino()

public override MappingSelectionInfo GetSelectionInfo()
{
try
List<RhinoObject> selection = RhinoDoc.ActiveDoc.Objects.GetSelectedObjects(false, false)?.ToList();
Copy link
Contributor

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

Copy link
Member

@AlanRynne AlanRynne left a 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

@AlanRynne AlanRynne self-requested a review January 8, 2024 16:45
Copy link
Member

@AlanRynne AlanRynne left a 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.

@AlanRynne AlanRynne merged commit 5bf6a8d into dev Jan 9, 2024
30 checks passed
@AlanRynne AlanRynne deleted the CNX-8388-Handle-CA1031-warnings-in-Rhino-projects branch January 9, 2024 09:04
@JR-Morgan JR-Morgan added this to the 2.18 milestone Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants