CollinAlpert / Lombok.NET

.NET adaptation for Java's Lombok using Source Generators.
MIT License
311 stars 16 forks source link

IntelliSense does not recognize generated constructors #3

Closed CollinAlpert closed 2 years ago

CollinAlpert commented 2 years ago

Generated code with the NoArgsConstructor, AllArgsConstructor and RequiredArgsConstructor attributes does not get picked up by IntelliSense. The constructors can be used and the build passes without issues, however it would be nice if IntelliSense also recognized a presence of the generated constructors. This issue is observed in Visual Studio 2022 as well as Rider 2021.3.2.

derSchtefan commented 2 years ago

Since SourceGenerators are fairly new, maybe a feature request or bug report to VS 2022 and Rider is in order?

CollinAlpert commented 2 years ago

Yes, I'm currently working on a minimal repro.

CollinAlpert commented 2 years ago

Actually I can't reproduce this issue in Rider anymore. Must be specific to VS 2022 and I am kind of hoping that it will fix itself. I will still keep an eye on this, though.

Neo-vortex commented 2 years ago

I am actually experiencing the same issue with latest rider [JetBrains Rider 2021.3.2] image

CollinAlpert commented 2 years ago

Interesting. The past few days it has been on and off for me as well. I will write up a bug ticket for ReSharper this week.

CollinAlpert commented 2 years ago

I think I am getting closer to diagnosing this issue. My current implementation of the Source Generators throws an exception when code cannot be generated (e.g. when a partial modifier is missing). This seems to cause issues in the IDE (see https://youtrack.jetbrains.com/issue/RIDER-74077). I will remove the thrown exceptions and replace them with Roslyn Analyzers. Hopefully this will solve the problem.

Neo-vortex commented 2 years ago

I think I am getting closer to diagnosing this issue. My current implementation of the Source Generators throws an exception when code cannot be generated (e.g. when a partial modifier is missing). This seems to cause issues in the IDE (see https://youtrack.jetbrains.com/issue/RIDER-74077). I will remove the thrown exceptions and replace them with Roslyn Analyzers. Hopefully this will solve the problem.

in this https://github.com/CollinAlpert/Lombok.NET/issues/3#issuecomment-1021021082 the class is already partial. are you sure it is related to this ?

CollinAlpert commented 2 years ago

The problem is not being the class being partial or not, but the generator throwing an exception (e.g. when the partial modifier is removed for a short period of time) and then Rider/ReSharper never recovering from that.

I can reproduce this. Create a new project, everything works fine until your remove and add the partial modifier. Then it stops working.

CollinAlpert commented 2 years ago

So it seems my recent changes haven't much effect either. I finally managed to create an issue for Rider: https://youtrack.jetbrains.com/issue/RIDER-74469

CollinAlpert commented 2 years ago

Fixed in ee788bb01a6e62eaa1bf5923853479b0b57a6241.

tianmafly commented 2 years ago

image image image

Lombok 1.2.2 version. vs2022 17.35 version build is sucessful and exe can run。but show some error。 IntelliSense does not recognize?

CollinAlpert commented 2 years ago

@tianmafly There are some IntelliSense issues around Source Generators in Visual Studio and Rider. Can you try closing and reopening the solution? Does the error persist after that?

tianmafly commented 2 years ago

@CollinAlpert Close and reopen the solution, the error persist.

CollinAlpert commented 2 years ago

Can you send me a reproduction?

tianmafly commented 2 years ago

I new create a simple solution,it is ok. The solution I am using is complex, maybe some nuget package conflict?

CollinAlpert commented 2 years ago

@tianmafly Is your solution on GitHub so that I could take a look?

tianmafly commented 2 years ago

sorry, it is not in GitHub. It is private project of company.

CollinAlpert commented 2 years ago

No worries. I am, however, going to need some form of reproduction to be able to diagnose an issue. I use this library in many larger projects and have not seen any major issues with IntelliSense so far.