-
Notifications
You must be signed in to change notification settings - Fork 15
Cannot resolve imports #25
Comments
Hi, |
After quick Googling it does not appear that Rider and .NET platform has the concept of "project source root" that Java and IntelliJ IDEA has. I know what you mean, but I can't find anything like that in the IDE and Googling for it didn't come up with anything useful. Next I took a look at your alternative suggestion of Protocol Buffer Import path settings. By default mine looks like this: It doesn't exactly look like something that's inviting me to fiddle with it, so I won't touch it. I don't understand what it's supposed to do and that default path looks very funky to me and nothing like in the examples. I read the readme section about path settings ~6 times carefully and... I'm not really none the wiser for it. Maybe it's a Java vs. dotNET thing or maybe I'm just stupid, I don't know. I'm not sure what you mean by "editor doesn't assume that the imports are in the same directory" either - it doesn't really matter what directory the proto files are at. It doesn't work as I would expect it to work even if they are at another folder. Defining the path does absolutely nothing. I even get auto-suggestions for the path and file names - from your plugin I would assume - and for a moment there everything is OK, but then the path turns red again. Intuitively - as an end user - since I have a path in the import-statement, I would just simply expect the plugin to work. I don't know how it works under the hood - or why - but if I have a perfectly functional import statement defined I would just simply expect it to work without jumping through any additional hoops. There's probably some really good technical reason why it doesn't work like that which is beyond my current understanding. But, as it stands, the easiest option in my Rider and .NET environment would simply seem to be uninstalling this plugin. I only wanted the plugin for syntax highlighting and syntax parsing since the IDE automatically suggested to me, I was like "Hm? Ok, I'll click install", and obviously it's not doing that for me correctly out of the box - for whatever reason. So, if this is a "not-going-to-fix" (or can't fix because of X) issue for you, then I'm just simply going to uninstall the plugin to get rid of the incorrect and annoying red highlights. In case you are interested in refactoring your code in some sensible fashion so that it just works, let me know. I'm happy to test it for you. And if not, no harm done. Peace. |
@jvolkman Could the default proto paths be loaded from the *.csproj files for C# projects? It seems that the ProtoRoot property could be defined within it. (found that in this documentation), not really sure about that, just one naive guess) |
Certainly if that's a popular convention in C# projects it could be used as a hint. |
@jvolkman yes it is a popular convention, can you please implement it? |
@jvolkman And adding my directory path to the list just isn't working. |
@RayMMond it looks like you may be missing |
Yes.. It works after adding |
Webstorm has this problem too. |
Which editor version is this @Marvvyn? Does your color scheme make numbers red, or are those also errors? |
I completely disagree with "current directory is not searched" Imagine your C compiler telling you |
For me even that doesn't work! I click the "+" button, it opens "Select Path" dialog but it forces me to chose a specific file. Ok, I chose the file and click "Open". Dialog closes but nothing is added to the list! Nothing! Tried everything, no way to add new entries in the list :( Protocol Buffer Editor: 2.1.0 |
@xirius I'll see if I can reproduce with the versions you've listed. I haven't heard of that behavior. What OS are you using? One way that you may be able to work around that:
Here's what mine looks like:
|
I have the same issue. However this workaround helps a little bit. I still don't see the colors that I set in the rider for proto files but at least the errors are gone now. EDIT: It does not not ignore color settings completely. I can change color of numbers, strings, etc. Keywords always use the color of identifiers. |
@Marvvyn do error annotations work? For example, a field name or number specified twice? |
@jvolkman yes they work. |
Behavior: Same as xirius / Marvvyn; whereby some proto references were missing and attempting to add the folder location through the settings required me to find a file. When said file was clicked, the application would return to the previous settings window with no new values added. Manually editing the project files to add the root folder of the project (edited after further research) resulted in the new folder reference to appear in the settings and for the references to be picked up in the code, removing the errors I was getting before. Syntax coloring does work for me, and was prior to the changes for the file. Only syntax errors indicated a potential issue. Edit: While working on a solution, adding the folder of the project with the *.proto file folder structure fixes lookup references while working within the solution context. Context: Manually added *.proto files to project in order to support gRPC over HTTP in .NET Core. Added *.proto files in a created google/api folder. When importing these references into my own *.proto files, attempts to reference google.api.http caused an error to be highlighted in the editor on the api portion of google.api.http. References were picked up by build tools / Visual Studio 2019 Community and the service would run correctly. Only errors appeared to be highlights in Rider. Similarly manually added *.proto files in a protobuf subfolder to support timestamp and wrappers did not throw errors and worked flawlessly even before the Project files editing. It's possible these are already in the jar file that comes with the plugin? IDE info: JetBrains Rider 2020.3.2 Default value of importPathEntries after the plugin installation. This did not change whether autoConfigEnabled was on or not, file://$PROJECT_DIR$ was not present.
|
Here's how I fixed this. (Rider 2020.3.3 on MacOS 11.1)
As long as I use the relative path from the selected directory, I'm able to resolve my imports within Rider. Thanks for the great plugin, @jvolkman |
Well, actually - default imports still doesn't work in Rider) |
What to do for disappearing red errors in proto? |
There seems to be a problem with the plugin showing incorrectly that imports were not resolved even though they are:
Everything is working just fine and the imported file is available and found in the folder.
I can compile it no problem with this import line. It's just the editor which is incorrectly showing it red and giving "Cannot resolve imports."
To double confirm if I change the name of the file to something incorrect - it then fails to compile. If I change it back it compiles just fine.
Ie. it seems to be a Protocol Buffer Editor problem.
I am using Rider 2020.1.4 on Ubuntu Linux and I have Protocol Buffer Editor version 2.0.
Thank you for your continued development and support of this crucial plugin. Stay safe and healthy.
The text was updated successfully, but these errors were encountered: