public WriteEventOverloadInfo(IMethodSymbol sourceMethod, GenerationOptions options, ParameterConverterCollection converters)
         {
            if (sourceMethod == null)
               throw new ArgumentNullException("sourceMethod", "sourceMethod is null.");

            if (options == null)
               throw new ArgumentNullException("options", "options is null.");

            if (converters == null)
               throw new ArgumentNullException("converters", "converters is null.");

            m_sourceMethod = sourceMethod;
            m_options = options;
            Parameters = m_sourceMethod.Parameters.Select(p => new EventParameterInfo(p, options, converters.TryGetConverter(p.Type))).ToImmutableArray();
         }
      private EventSourceGenerator(Document document, Compilation compilation, SyntaxTree syntaxTree, CompilationUnitSyntax root, SemanticModel semanticModel, FrameworkName targetFramework)
      {
         if (document == null)
            throw new ArgumentNullException("document", "document is null.");

         if (compilation == null)
            throw new ArgumentNullException("compilation", "compilation is null.");

         if (syntaxTree == null)
            throw new ArgumentNullException("syntaxTree", "syntaxTree is null.");

         if (root == null)
            throw new ArgumentNullException("root", "root is null.");

         if (semanticModel == null)
            throw new ArgumentNullException("semanticModel", "semanticModel is null.");

         m_targetFramework = targetFramework;
         m_document = document;
         m_compilation = compilation;
         m_syntaxTree = syntaxTree;
         m_root = root;
         m_semanticModel = semanticModel;

         EventSourceTypes = ImmutableList.CreateRange(new[]
                 {
                        m_compilation.GetTypeByMetadataName("System.Diagnostics.Tracing.EventSource"),
                        m_compilation.GetTypeByMetadataName("Microsoft.Diagnostics.Tracing.EventSource")
                    }
                 .Where(s => s != null)
                 .Select(s => new EventSourceTypeInfo(m_semanticModel, s)));

         if (EventSourceTypes.Count == 0)
            throw new CodeGeneratorException("The class System.Diagnostics.Tracing.EventSource or Microsoft.Diagnostics.Tracing.EventSource could not be found. You need to add a reference to the assembly containing one of these classes to continue.");

         m_generator = SyntaxGenerator.GetGenerator(document);
         m_parameterConverters = new ParameterConverterCollection(m_semanticModel, m_generator);
      }
Exemplo n.º 3
0
            public WriteEventOverloadInfo(IMethodSymbol sourceMethod, GenerationOptions options, ParameterConverterCollection converters)
            {
                if (sourceMethod == null)
                {
                    throw new ArgumentNullException("sourceMethod", "sourceMethod is null.");
                }

                if (options == null)
                {
                    throw new ArgumentNullException("options", "options is null.");
                }

                if (converters == null)
                {
                    throw new ArgumentNullException("converters", "converters is null.");
                }

                m_sourceMethod = sourceMethod;
                m_options      = options;
                Parameters     = m_sourceMethod.Parameters.Select(p => new EventParameterInfo(p, options, converters.TryGetConverter(p.Type))).ToImmutableArray();
            }