I'm using Analyzer with Code Fix template of .NET Compiler Platform SDK to create my Roslyn code analyzer. The template creates a solution, where the actual analyzer project is a multi-target one. (I did not find a way, to modify this.)
Now I want to do something simple: accessing a file containing some setup data while initializing my analyzer.
Actually, it turns out, that I cannot create a TextReader because .net 4x and .net core are using different kinds of namespaces, System.IO.File for example, is in a different assembly in the two above cases. I should install a NuGet package (System.IO.FileSystem) to access System.IO.File, but I can not do this, because the given package is not multi-target.
Does not work:
using (TextReader reader = new File.OpenText(@"filepath"))
{
....
}
... because File needs NuGet package, which I can not install.
Does not work either:
using (TextReader reader = new StreamReader(@"filepath"))
{
....
}
... because StreamReader does not have the signature with a single string parameter, only the stream based ones are accessible.
Now I'm confused. How do I use TextReader in such a multi-target project?