antmicro-labs / renode

Renode - Antmicro's virtual development framework for complex embedded systems
https://renode.io
Other
4 stars 0 forks source link

FYI: How to use completion in non-Rider IDE #9

Open PiotrZierhoffer opened 3 years ago

PiotrZierhoffer commented 3 years ago

You can take a look at https://github.com/betrusted-io/xous-core/tree/master/emulation#editing-renode-peripherals

It boils down to creating a specifc csproj that has proper references. I have not tested it, but you might be able to employ this approach if needed.

John15321 commented 3 years ago

No tweaks to any .csproj files are needed. I managed to make IntelliSense work on VSCode with 3 things:

  1. Make sure you have installed needed .NET SDKs etc, and mono. Also make sure that they are correctly added to your path so for example when you execute:
    
    $ dotnet --info
    .NET SDK (reflecting any global.json):
    Version:   5.0.202
    Commit:    db7cc87d51

Runtime Environment: OS Name: ubuntu OS Version: 20.04 OS Platform: Linux RID: ubuntu.20.04-x64 Base Path: /usr/share/dotnet/sdk/5.0.202/

Host (useful for support): Version: 5.0.5 Commit: 2f740adc14

.NET SDKs installed: 3.1.408 [/usr/share/dotnet/sdk] 5.0.202 [/usr/share/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 3.1.14 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.14 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download

You can see your .NET SDKs etc.
The same with mono:
```bash
$ mono --version
Mono JIT compiler version 6.12.0.122 (tarball Mon Feb 22 17:29:18 UTC 2021)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           __thread
    SIGSEGV:       altstack
    Notifications: epoll
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug 
    Interpreter:   yes
    LLVM:          yes(610)
    Suspend:       hybrid
    GC:            sgen (concurrent by default)
  1. Install the C# extension and configure it. You have to tweak 2 settings in this extension:

Set it to use your global mono (in your User settings). By either adding this JSON line to your config:

"omnisharp.useGlobalMono": "always"

Or just toggle it in the settings:

image

  1. Then make sure that your default project solution is set to Renode.sln. by either adding this JSON line to your local .vscode/settings.json:
"omnisharp.defaultLaunchSolution": "Renode.sln"

Or do it using VSCodes GUI for settings like so (just make sure that you are in the Workspace tab, otherwise Omnisharp will try to start every C# project you open in VSCode with a Renode.sln solution):

image

After following these 3 steps you should restart VSCode, after that it will probably prompt you about a few problems but you should ignore them, but also agree if its asking to "Restore" some missing dependencies, etc. Open a .cs file (for example: renode/src/Renode/Network/NetworkServer/NetworkServer.cs, for it to fully parse the renode project it needs a few minutes so just wait. When it finished your VSCode should look something like that, with references, authors, etc shown:

image

and when you hover over a function or ash VSCode to get you to its Definition etc it also should work:

image

PiotrZierhoffer commented 3 years ago

I confirm this works. We'll consider how to put it in our docs, thanks