Home

LP7 does not handle implicit usings

I #load-ed some .cs files from a project that has implicit usings enabled and LP7 would not compile the files until I added the namespace or a "using" to the file.

For example, a property declared like this:

public DateTime StartDate { get; set; }

did not work unless I changed the declaration to System.DateTime or added "using System;" to the file.

Is there any way to work around this? The files are really from a Visual Studio project so I'd rather not clutter them up with a bunch of uneccessary (from the perspective of VS) usings.

Comments

  • Create a statements-based query or a .cs file with the following content:

    global using global::System;
    global using global::System.Collections.Generic;
    global using global::System.IO;
    global using global::System.Linq;
    global using global::System.Net.Http;
    global using global::System.Threading;
    global using global::System.Threading.Tasks;
    

    Save this to a file called something like "iusing.linq" or "iusing.cs".

    Then in your query, #load that file (along with the other .cs files you wish to import):

    #load "iusing"
    

    or

    #load "iusing.cs"
    
  • Perfect - thanks for the quick response @JoeAlbahari; I should have thought of that!

    Thanks for making such a great application; I use it constantly :)

Sign In or Register to comment.