c# - InternalsVisibleTo attribute ignored when compiling solution via Roslyn -


so developing roslyn-based frontend compiler parses c# solution, performs rewriting on syntax trees desugar constructs of dsl, , uses roslyn apis compile , emit executables/dlls. last part, given compilation, done (some details omitted clarity):

var compilation = project.getcompilationasync().result;  var compilationoptions = new csharpcompilationoptions(outputkind,   compilation.options.modulename, compilation.options.maintypename,   compilation.options.scriptclassname, null,   compilation.options.optimizationlevel, compilation.options.checkoverflow,    false, compilation.options.cryptokeycontainer,    compilation.options.cryptokeyfile, compilation.options.cryptopublickey,    compilation.options.delaysign, platform.anycpu,    compilation.options.generaldiagnosticoption,    compilation.options.warninglevel,   compilation.options.specificdiagnosticoptions,   compilation.options.concurrentbuild,    compilation.options.xmlreferenceresolver,   compilation.options.sourcereferenceresolver,   compilation.options.metadatareferenceresolver,   compilation.options.assemblyidentitycomparer,   compilation.options.strongnameprovider);  var targetcompilation = csharpcompilation.create(assemblyfilename,   compilation.syntaxtrees, compilation.references,   compilationoptions);  emitresult emitresult = null; using (var outputfile = new filestream(filename, filemode.create, fileaccess.write)) {   emitresult = targetcompilation.emit(outputfile);   if (emitresult.success)   {     return filename;   } } 

so works fine, until tried compile solution project declares internal classes/fields, , uses [assembly: internalsvisibleto("...")] attribute (in assemblyinfo.cs file) give visibility of these internals project b.

directly compiling using visual studio works fine , allows b see these internal declarations of a. however, when try compile through tool using roslyn apis, internalsvisibleto attribute ignored, , getting errors, such as:

error cs0122: ... inaccessible due protection level

which means internalsvisibleto not picked up.

i expecting roslyn automatically pick parsed project info, wondering if have enable specific compilation option or add information manually?

i have looked around cannot find similar question or answer, unless missing something. can give more information if required. thanks!


Comments

Popular posts from this blog

What Are The Best Universities In The World?

Hard vs. Soft Water: What's The Difference?

Why People Get Naked Before Freezing To Death