Home > Software design >  .cs file stand alone no syntax error checking at all, no library auto detection for c#
.cs file stand alone no syntax error checking at all, no library auto detection for c#

Time:09-08

I am not new to coding and I know I have never had this issue.

In Visual Studio if I just create a .cs file and check it's intellisense nothing works. auto complete for using. does not work, nor does simple syntax checking work (see image)

Am I crazy? Can someone else try this out, what am I missing?

NOTE this only happens when I just have a .cs file for an external script. I just need simple auto complete and syntax checking to work

example

CodePudding user response:

A C# file is somewhat meaningless without a project file. Versions, references, etc… all depend upon having a build system. This is a somewhat pedantic truth, but it is how VS works. Pathologically, I could have a CS file Console.WriteLine(“Hello world!”); which in one project results in hello world, and in another results in the program formatting a disk.

Add the CS file to a project, or create one. If you frequently come across this issue in some unique use case, visual studio may not be the best editor for the job. VS Code or another more lightweight tool may be better suited.

  • Related