Using .cs files like .py files
I was recently playing with Python as part of doing some Raspberry Pi/IoT programming. I found aspects of the Python experience superior to what we have with C# / .NET SDK. I really wish we could have these nice things.
I spent a bunch of time in this directory: https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3731/tree/main/examples
There were two really nice things about that:
- I could type
python filename.pyto run any of those files w/o the complication of project files. - I could type
python -i filename.pyto run a given program and then end up in an interactive experience.
The second experience was particularly useful. Much of IoT programming is carefully constructing bytes to send to a device. I was able to use these correctly written programs as a way to explore constructing bytes and then send them to the device and see if they did the right thing. With some trial and error, I was able to write the correct C#. I now have the correct C#, but I was use this same python interactive environment again since it is so easy to use. I'm sure that there are other domains that would benefit from the same thing.
The downside of the Python experience is that I had to discover and install the Adafruit PyPI packages I needed manually. Nothing told me what those were (even the code doesn't tell me that). Clearly, we wouldn't want that.
For our IoT repo, we have an unfortunate scheme of managing samples that would benefit from something better: https://github.com/dotnet/iot/tree/main/src/devices/Display/samples. We're clearly fighting msbuild here.
Like it, it would make the C# more popular, and I'm working on a dotnet tool to execute the C# script without a project file https://github.com/WeihanLi/dotnet-exec, hope it would be helpful for someone