ale icon indicating copy to clipboard operation
ale copied to clipboard

Auto detect used C# libraries

Open abitrolly opened this issue 3 years ago • 1 comments

When using mcs on Fedora, ALE doesn't detect used assemblies and requires them to be added manually, such as System.Net.Http in the example below. Is would be nice if ALE could detect those and do not fail with the error.

  using System;
  using System.Net.Http;
  
  class Program
  {
>>    static HttpClient Client = new HttpClient();
  
      static void Main(string[] args)
      {
  
          var hyper = "inter";
          Console.WriteLine($"string {hyper}polation");
      }
  }
~                                                                                                                          
~                                                                                                                          
~                                                                                                                          
CS0246: The type or namespace name `HttpClient' could not be found. Are you missing an assembly reference?

abitrolly avatar Mar 30 '21 20:03 abitrolly

ALE doesn't detect used assemblies and requires them to be added manually

For those who came here after online search of the similar error:

CS0246: The type or namespace name `...' could not be found. Are you missing an assembly reference?

After disabling and enabling linters I found it's only csc and mscs that are having issues and to make them find assemblies in Godot projects it's enough to add following two lines to .vimrc:

let g:ale_cs_csc_assemblies = ['.mono']
let g:ale_cs_mcsc_assemblies = ['.mono']

TBH, IDK how ALE would know to look in .mono otherwise. Is it a standard assemblies location for all Mono projects? Is this why csharp-ls finds them out of the box?

cprn avatar Jun 10 '22 12:06 cprn

Same issue occurred for me in nvim with it throwing the false error CS0518: Predefined type 'System.Runtime.CompilerServices.NullableContextAttribute' is not defined or imported in a fairly standard .NET 7.0 project. It's been almost 2 and a half years with no out-of -the-box fix now, so I hope this gets addressed at some point to make the solution easier to find, even if it's just stating for people using mono in their projects to use the above lines in their .vimrc

LandonDeam avatar Aug 13 '23 06:08 LandonDeam