Closed heba-eiz closed 3 years ago
@heba-eiz Did you solve this issue? Perhaps you have a solution for people who also have this issues?
@arendvw I couldn't find a solution to get it to work on Visual Studio but it works on Visual Studio Code so I ended up using that.
I truly can't thank you enough for this plugin! I hated the gh editor so much and your plugin just made coding pleasant again :)))
I have the same issue btw, and dont want to use extra programs. If anyone finds a solutions would be awesome... What I can think of is that VS does not use the regular way to save files so no events are triggered to reload the contents to GH.
@dilomo I actually found a work around to get it to work with VS, a bit of a weird one but it works :) Basically after you open the project once in VS (to load the assemblies), you open the code in both VS and VS Code, I do the edit in VS, and every time I save the VS, I see the VS code updated (even while it is open, you don't have to open and close it), then I simply save VS Code, and VIOLA! It is right there in gh editor :)
@heba-eiz Thats interesting solution. But it seems that the file watcher inside script parasite cannot detect files saved by VS.. That's one more pleasant thing about using windows hah
Watcher = new FileSystemWatcher(directory, filename)
{
NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.CreationTime
};
Watcher.Changed += OnFileChanged;
> Watcher.Created += OnCreated;
Watcher.Deleted += OnFileChanged;
Watcher.EnableRaisingEvents = true;
Message = "Watching";
Maybe there is something missing here? Not sure what is happening there but prob event is not detected.
I would love to edit and try but what is ScriptComponents?
This is how the code should be changed to work for visual studio:
Ok I have good news. I fixed several things around in the code without changing too much:
The question I have to @andrewheumann is how do I upload my changes now? I can push back or make a separate branch? I also dont have rhino 6 so I compiled against 7 and .NET 4.8.
Cheers
@dilomo I think you'll need me and not andrew, but the easiest way for me is that you:
This is the nicest way, and you'll be credited as an author on github here.
If this is somehow does not work, you can always just give me a zipped folder and I'll figure out the changes on my end.
@arendvw sorry I thought I tagged you last post.
I think I did it but not sure. You should be able to see the pull request now.
Yes! I see it, I'm working on testing the result
On Tue, 17 Aug 2021 at 12:33, Anton Kerezov @.***> wrote:
@arendvw https://github.com/arendvw sorry I thought I tagged you last post.
I think I did it but not sure. You should be able to see the pull request now.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arendvw/ScriptParasite/issues/3#issuecomment-900182303, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAL7T5J7JLOZGZFIPDTTPQDT5I3IFANCNFSM467FD5AA . 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&utm_campaign=notification-email .
-- StudioAvw +31 (0) 623584904 Stationsweg 11 2515BG Den Haag
Thanks Just as a comment btw, there might be needed some more work on first load of files with the plugin. If a gh file has a ScriptParasite and it is set to enabled the contents that are written to the external file always come with a lot of white spaces. I tried to account for it but maybe has to be better tested in different use cases. If the script is "saved" by pressing ok on the C# window formatting should be perfect. If you get a lot of spaces and you opened an old document is better to replace ScriptParasite component with the latest version. So maybe its good idea to show the current version inside the tooltip description.
I just added another commit with some more fixes. You can see detailed log in the pull request. I think if we could only manage to fix the wrong indentation for additional usings would finish all open issues right now.
@dilomo thanks a lot for all your effort! This has been very very helpful.
I did not directly merge your requests, because of some problems:
Does this solve your problem?
Looking at the new code looks next level to me 🥇 I compiled against Rhino7 and I see some issues that i kind of fixed but are not yet working for me..
private bool WriteScriptToFile(Component_CSNET_Script script, string filename)
{
//only write the changed files and skipp attribute changes so that disk wear is decreased
var usingHash = GetStringSha256Hash(script.ScriptSource.UsingCode);
var sourceHash = GetStringSha256Hash(script.ScriptSource.ScriptCode);
var additionalHash = GetStringSha256Hash(script.ScriptSource.AdditionalCode);
// always change on attribute modification
if (AttributeTrigger || usingHash != UsingHash || sourceHash != SourceHash || additionalHash != AdditionalHash)
{
// save for next run
UsingHash = usingHash;
SourceHash = sourceHash;
AdditionalHash = additionalHash;
// can write now ... <skipped code here>
}
else
// simulate write as the text is the same as the previously written one
return true;
}
The attribute trigger is triggered on all other events except SolutionExpired. I think it could be MD5 checksum as well or at least thats the way I devised. This is a way to avoid always saving on Solution Expired event even tho there are no changes. Also if the file is big saving takes time.
Actually it is a bit unpredictable:
What is most important for me is (check is so far working)
Can you send a binary or upload in the branch so I can try directly some other dll I uploaded my compiled version in my fork's releases. I think on my computer all mentioned works. So difficult to make it for wide audience 😅
@dilomo Thanks for the great checklist, this helps a lot.
I've changed some logic that checks when to write: this should work better now on attribute changes. I'm not yet able to reproduce the part where it stops working with events when working with visual studio.
Indeed, it's very difficult to test, with different editors, different platforms and different behaviours.
Attached is a binary version of the last master branch (also on food for rhino as 1.1.1 beta
@arendvw Great job! Now it works as it should (your binary) and I think you made a lot of people very happy with this new release. Thanks for the effort and quick fixes.
As far as optional stuff everyone can download and modify as they please.
Awesome, thanks for the testing, this helps a lot! I've just changed the 1.1.1 on food4rhino to non-beta, and I'll now release it to yak. I'll open a separate issue for the optional stuff.
Thank you so much for this amazing plugin! I always hated the built-in editor of c# in grasshopper and this plugin is a huge help!
Unfortunately, I only managed to get it to work once and then I am no longer able to get it to work.
I get the VS project file and it gets updated when I edit the c# component from gh, but the changes I do in VS don't get sync to Gh after I save the VS file.
(it somehow worked when I used Notepad++ but not VS)
Any idea of any possible problem in my settings?