arendvw / ScriptParasite

A component that allows editting of C# definitions in external editors
21 stars 5 forks source link

Endregion is screwing up the cs file #12

Open Sonderwoods opened 2 years ago

Sonderwoods commented 2 years ago

I've ported a scriptcomponent to a cs file and opening it in VS.

When I add region and endregion in VS, then the scriptcomponent somehow removes everything after the endregion part, see below.

image

image

and suddently all my code after the endregion is gone: image

Sonderwoods commented 2 years ago

would guess the problem lies here

https://github.com/arendvw/ScriptParasite/blob/40abb4af037b646257337af76af8254a743165b4/Component/ScriptParasiteComponent.cs#L554

arendvw commented 2 years ago

Can you share a file that you expect to work, but currently does not?

On Wed, Oct 6, 2021, 11:07 Mathias Sønderskov Schaltz < @.***> wrote:

would guess the problem lies here

https://github.com/arendvw/ScriptParasite/blob/40abb4af037b646257337af76af8254a743165b4/Component/ScriptParasiteComponent.cs#L554

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/arendvw/ScriptParasite/issues/12#issuecomment-935801492, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAL7T5K33E4CUSKUNX3HBI3UFQGWRANCNFSM5FN6GITQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

arendvw commented 2 years ago

@Sonderwoods Currently the parser only supports the region that a script component in grasshopper supports as well. (RunInstance region, and additional components region).

I have no way to solve this; I can only give you and error that you have more regions than what fits in a grasshopper component.

Sonderwoods commented 2 years ago

@arendvw im not asking for going outside of grasshopper c# components boundaries. but it fails if i use #region and #endregion within the RunScript method!

Without scriptparasize, this works fine in and is legal c# script components.. image

arendvw commented 2 years ago

Awesome. I did not know it is possible to nest regions. Today, I learned.

Right now the problem is that I use the area between > #region Runscript and the first #endregion it encounters to copy paste this code back intro grasshopper.

The nicest way to solve this would be to instead of using regex, to use Roslyn (the microsoft C# compiler).

Another way would be to change the regex to follow howmany #regions it has encountered to get the snippet.

Either way, I will need some time to solve this.

Sonderwoods commented 2 years ago

Or continue to the last #endregion and not care about nesting hierarchy. I think that could work as a quick fix. Anyway thanks for looking into this whenever time appears on the other side of December :D enjoy the holidays

arendvw commented 2 years ago

Or continue to the last #endregion and not care about nesting hierarchy

The one before the last (that's the additional code region), except if the additional code region also contains nested regions.