private void AddMessage(Diagnostic diagnostic)
        {
            var messageType = RoslynConvert.ConvertMessageType(diagnostic.Severity);
            var textSpan    = RoslynConvert.ConvertTextSpan(diagnostic.Location.SourceSpan);

            var message = new CompilationMessage(messageType, textSpan, diagnostic.GetMessage());

            _messages.Add(message);
        }
Example #2
0
        private static CSharpCompilation CreateCompilation(IEnumerable <SyntaxTree> syntaxTrees,
                                                           IEnumerable <string> assemblyFiles,
                                                           CompilationPackage compilationPackage, CompilationOutput compilationOutput)
        {
            var assemblyName = compilationPackage.AssemblyName;

            if (string.IsNullOrWhiteSpace(assemblyName))
            {
                assemblyName = FileSys.Path.ChangeExtension(FileSys.Path.GetRandomFileName(), ".dll");
            }

            var references = GetReferences(assemblyFiles);

            var compilation = CSharpCompilation.Create(assemblyName, syntaxTrees, references,
                                                       new CSharpCompilationOptions(RoslynConvert.ConvertOutputKind(compilationOutput.OutputKind)));

            return(compilation);
        }