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

Add simple diagnostic output to InterfaceStubGenerator. #79

Merged
merged 7 commits into from
Dec 8, 2014

Conversation

nekresh
Copy link
Contributor

@nekresh nekresh commented Dec 3, 2014

@anaisbetts
Copy link
Member

Does this work in Xamarin Studio on OS X?

@nekresh
Copy link
Contributor Author

nekresh commented Dec 3, 2014

Can't install Xamarin Studio on my mac (OS X version too old) but it should just work: http://forums.xamarin.com/discussion/13117/can-xamarin-recognize-warnings-errors-produced-by-custom-build-commands
I'll test with Xamarin Studio for Windows.

@anaisbetts
Copy link
Member

Looks like it works (on Xamarin Studio on Mac, that is). Lemme review this (or maybe @bennor can +1 it), then we'll merge it

@nekresh
Copy link
Contributor Author

nekresh commented Dec 3, 2014

Works for me too.

I made quite a big system for only this small change but I think more warnings/errors will come as the project get bigger.
I can shave a lot of code if you think all of it isn't necessary.

@bennor
Copy link
Contributor

bennor commented Dec 4, 2014

Firstly, awesome idea! 👍 I had no idea you could do that so easily. It works perfectly (in VS at least) and it's cool to be able to double-click the warnings to go straight to the busted method. 😸

⚠️ I did have a few concerns about the approach though:

  • Should we be raising warnings or errors? These methods are never going to do anything but fail hard at runtime, so wouldn't failing harder earlier with an error at build time be better?
  • The DiagnosticsLogger class seems a little heavy-handed. I personally would have replaced the Dump method with just a ToString() override on the Diagnostic class, and just flushed the errors out to the console as you loop over them the first time (in InterfaceStubGenerator). It doesn't feel like there's a lot of point having a class that rolls them up just to dump them out later as a in another loop if you're not doing anything else with them. Maybe I'm missing something though?
  • Lastly, just a couple of minor style things (which based on the rest of the project I think @paulcbetts agrees with), 🔥 the redundant this references (e.g. here and here, etc.) and there are a few brackets on the wrong lines - I'll try to point them out inline.

@paulcbetts that style manifesto you hinted at writing a while back would probably be helpful for people who are new to working on your stuff. 😉

var builder = new StringBuilder();

foreach (var diagnostic in diagnostics)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⬆️

@anaisbetts
Copy link
Member

that style manifesto you hinted at writing a while back would probably be helpful for people who are new to working on your stuff.

It's stuck on a machine I can't get to atm 😿

@bennor
Copy link
Contributor

bennor commented Dec 4, 2014

It's stuck on a machine I can't get to atm 😿

Ugh, that is the worst 😞

If only there were a place you could store files online and get to them from anywhere, eh? 😉

@anaisbetts
Copy link
Member

@bennor lol this was a surprise'ish machine death, it's actually on a Time Machine backup

@bennor
Copy link
Contributor

bennor commented Dec 4, 2014

Computers. 😭

@nekresh
Copy link
Contributor Author

nekresh commented Dec 5, 2014

I removed the this and put brackets on the right line.
I also removed the DiagnosticLogger class and its unit test.

Regarding messaging, I raised warnings as the compilation is working.
It is alright to throw errors at the developer but it will break already working code.

@nekresh
Copy link
Contributor Author

nekresh commented Dec 5, 2014

Regarding code style, I found a Visual Studio extension that can change VS settings when a settings file is present next to a solution.
If you have a VS settings file for C# code formatting, could you please add it to refit's repository ?

@anaisbetts
Copy link
Member

@nekresh There's a bunch of these, the problem is that nobody uses the same one. The most ubiquitous is Resharper Team Settings, but I don't use it :(

@bennor
Copy link
Contributor

bennor commented Dec 5, 2014

@paulcbetts I use ReSharper (I kind of hate it but hate writing boilerplate more, so I keep persisting with it 😞).

Anyway, I have a personal settings file that doesn't completely match the coding style but gets about 99% of the way there. I can check it in as a Team Shared file if you want? Then people who do use it won't unintentionally mangle the code.

It's just a XAML Resource Dictionary and the settings names are mostly clear enough that you should be able to validate the settings just by reading the file.

@bennor
Copy link
Contributor

bennor commented Dec 5, 2014

Other than loading LINQ queries into the condition of the loops, I think this is looking really good now.

I'm happy for it to be merged once that's taken care of. 👍

@nekresh
Copy link
Contributor Author

nekresh commented Dec 5, 2014

Would it be interesting to generate errors for unsupported constructions like properties in refit interface ?
It wouldn't compile anyway, as the generated code doesn't care about properties, but errors are cryptic.

@bennor
Copy link
Contributor

bennor commented Dec 5, 2014

I'm not sure about that. As you say, it will generate a fairly obvious error as it is, and there's only so much we can protect people from themselves.

@anaisbetts
Copy link
Member

Looking good. Thanks @nekresh!

anaisbetts added a commit that referenced this pull request Dec 8, 2014
Add simple diagnostic output to InterfaceStubGenerator.
@anaisbetts anaisbetts merged commit 6d78458 into reactiveui:master Dec 8, 2014
@bennor
Copy link
Contributor

bennor commented Dec 8, 2014

👍

@lock lock bot locked and limited conversation to collaborators Jun 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants