Why is Visual Studio reporting a lambda error in WebAPI working code on .Net Core?

I migrated WebAPI from FullDotnet (4.6) to .Net Core 2.0, and I had this problem in my data layer using Dapper.

My code is:

public List<Doctor> GetList() { List<Doctor> ret; using (var db = GetMySqlConnection()) { const string sql = @"SELECT D.Id, D.Bio, D.CRMState, D.CRMNumber, U.Id, U.Email, U.CreatedOn, U.LastLogon, U.Login, U.Name, U.Phone, U.Surname, U.Id, U.Birth, U.CPF, S.Id, S.Name from Doctor D inner join User U on U.Id = D.UserId inner join Speciality S on S.Id = D.IDEspeciality order by D.Id DESC"; ret = db.Query<Doctor, User, Speciality, Doctor>(sql, (doctor, user, speciality) => { doctor.User = user; doctor.Speciality = speciality; return doctor; } , splitOn: "Id, Id", commandType: CommandType.Text).ToList(); } return ret; } 

Strange behavior:

PrintScreen from code

Solution Build and WORK the Error that VisualStudio highlights:

The argument type 'lambda expression' is not assigned to the parameter type 'System.Func`5'

I have other classes with the same behavior and the same error, but, again, the code compiles and works , but this "highlight error" is annoying!

This is a highlight that I don’t have in my old solution using the .NET Framework 4.6

Useful information:

  • Class Library: .Net Standard 2.0
  • Visual Studio 2017 v15.4.1
  • Resharper 2017.2
+5
source share
1 answer

So, as we found out in the comments, the problem was caused by ReSharper (2017.2).

Some additional steps you can take when you suspect that ReSharper is acting.

Pause / resume ReSharper

To confirm that ReSharper is causing problems, you can pause it using:

Tools/Options.../Resharper node/Suspend now

In this case, just complete the pause / resume cycle and solve the problem.

ReSharper cache flushing ( source )

Broken caches affect the behavior of ReSharper. For example, ReSharper may stop enabling characters, or some navigation commands may not be available. If you notice this strange behavior, clearing the caches for the current solution can help in most cases.

Clear caches for current solution

  • Open the solution with supposedly broken caches in Visual Studio.
  • Open Wednesday | ReSharper general options page.
  • Click Clear Caches. Please note that caches will only be cleared at the currently selected cache location.
  • Open your decision for the change to take effect.

ReSharper also automatically clears solution caching if a specific solution has not been opened for more than 30 days.

What if the above does not work?

If you have confirmed that this is a ReSharper problem, you should first try and upgrade to the latest version of ReSharper and try to reproduce your problem.

If the problem still persists, you should go to the JetBrains error tracker and report an error after confirming that it is no longer an error.

+2
source

Source: https://habr.com/ru/post/1272913/


All Articles