コード例 #1
0
 public ExtractMetadataWorker(ExtractMetadataInputModel input, bool rebuild)
 {
     _rawInput   = input;
     _validInput = ValidateInput(input);
     _rebuild    = rebuild;
     _preserveRawInlineComments = input.PreserveRawInlineComments;
     _filterConfigFile          = input.FilterConfigFile?.ToNormalizedFullPath();
 }
コード例 #2
0
        public ExtractMetadataWorker(ExtractMetadataInputModel input)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (string.IsNullOrEmpty(input.OutputFolder))
            {
                throw new ArgumentNullException(nameof(input.OutputFolder), "Output folder must be specified");
            }

            _files = input.Files?.Select(s => new FileInformation(s))
                     .GroupBy(f => f.Type)
                     .ToDictionary(s => s.Key, s => s.Distinct().ToList());
            _references = input.References?.Select(s => new FileInformation(s))
                          .Select(f => f.NormalizedPath)
                          .Distinct()
                          .ToList();
            _rebuild = input.ForceRebuild;

            var msbuildProperties = input.MSBuildProperties ?? new Dictionary <string, string>();

            if (!msbuildProperties.ContainsKey("Configuration"))
            {
                msbuildProperties["Configuration"] = "Release";
            }

            _options = new ExtractMetadataOptions
            {
                ShouldSkipMarkup          = input.ShouldSkipMarkup,
                PreserveRawInlineComments = input.PreserveRawInlineComments,
                FilterConfigFile          = input.FilterConfigFile != null ? new FileInformation(input.FilterConfigFile).NormalizedPath : null,
                MSBuildProperties         = msbuildProperties,
                CodeSourceBasePath        = input.CodeSourceBasePath,
                DisableDefaultFilter      = input.DisableDefaultFilter,
            };

            _useCompatibilityFileName = input.UseCompatibilityFileName;
            _outputFolder             = StringExtension.ToNormalizedFullPath(Path.Combine(EnvironmentContext.OutputDirectory, input.OutputFolder));

            _workspace = new Lazy <MSBuildWorkspace>(() =>
            {
                var workspace              = MSBuildWorkspace.Create(msbuildProperties);
                workspace.WorkspaceFailed += (s, e) =>
                {
                    Logger.LogWarning($"Workspace failed with: {e.Diagnostic}");
                };
                return(workspace);
            });

            var roslynLoader = new RoslynProjectLoader(_workspace);
            var fsharpLoader = new FSharpProjectLoader(msbuildProperties);

            _loader = new AbstractProjectLoader(new IProjectLoader[] { roslynLoader, fsharpLoader });
        }
コード例 #3
0
ファイル: ExtractMetadataWorker.cs プロジェクト: runt18/docfx
 public ExtractMetadataWorker(ExtractMetadataInputModel input, bool rebuild, bool useCompatibilityFileName)
 {
     _rawInput                  = input;
     _validInput                = ValidateInput(input);
     _rebuild                   = rebuild;
     _shouldSkipMarkup          = input.ShouldSkipMarkup;
     _preserveRawInlineComments = input.PreserveRawInlineComments;
     _filterConfigFile          = TypeForwardedToStringExtension.ToNormalizedFullPath(input.FilterConfigFile);
     _useCompatibilityFileName  = useCompatibilityFileName;
 }
コード例 #4
0
 public ExtractMetadataWorker(ExtractMetadataInputModel input, bool rebuild, bool useCompatibilityFileName)
 {
     _rawInput   = input;
     _validInput = ValidateInput(input);
     // To-do: enable rebuild option after dependency map is constructed
     _rebuild = true;
     _preserveRawInlineComments = input.PreserveRawInlineComments;
     _filterConfigFile          = input.FilterConfigFile?.ToNormalizedFullPath();
     _useCompatibilityFileName  = useCompatibilityFileName;
 }
コード例 #5
0
 public ExtractMetadataWorker(ExtractMetadataInputModel input, bool rebuild, bool useCompatibilityFileName)
 {
     _rawInput                  = input;
     _validInput                = ValidateInput(input);
     _rebuild                   = rebuild;
     _shouldSkipMarkup          = input.ShouldSkipMarkup;
     _preserveRawInlineComments = input.PreserveRawInlineComments;
     if (input.FilterConfigFile != null)
     {
         _filterConfigFile = Path.GetFullPath(Path.Combine(EnvironmentContext.BaseDirectory, input.FilterConfigFile)).Normalize();
     }
     _useCompatibilityFileName = useCompatibilityFileName;
 }
コード例 #6
0
        public ExtractMetadataWorker(ExtractMetadataInputModel input)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (string.IsNullOrEmpty(input.OutputFolder))
            {
                throw new ArgumentNullException(nameof(input.OutputFolder), "Output folder must be specified");
            }

            _files = input.Files?.Select(s => new FileInformation(s))
                     .GroupBy(f => f.Type)
                     .ToDictionary(s => s.Key, s => s.Distinct().ToList());
            _rebuild                   = input.ForceRebuild;
            _shouldSkipMarkup          = input.ShouldSkipMarkup;
            _preserveRawInlineComments = input.PreserveRawInlineComments;
            _useCompatibilityFileName  = input.UseCompatibilityFileName;
            _outputFolder              = input.OutputFolder;

            if (input.FilterConfigFile != null)
            {
                _filterConfigFile = new FileInformation(input.FilterConfigFile).NormalizedPath;
            }

            _msbuildProperties = input.MSBuildProperties ?? new Dictionary <string, string>();
            if (!_msbuildProperties.ContainsKey("Configuration"))
            {
                _msbuildProperties["Configuration"] = "Release";
            }

            _workspace = new Lazy <MSBuildWorkspace>(() =>
            {
                var workspace              = MSBuildWorkspace.Create(_msbuildProperties);
                workspace.WorkspaceFailed += (s, e) =>
                {
                    Logger.LogWarning($"Workspace failed with: {e.Diagnostic}");
                };
                return(workspace);
            });
        }
コード例 #7
0
ファイル: MetadataCommand.cs プロジェクト: tungnt185/docfx
        private Microsoft.DocAsCode.Metadata.ManagedReference.ExtractMetadataInputModel ConvertToInputModel(MetadataJsonItemConfig configModel)
        {
            var projects = configModel.Source;
            // If Root Output folder is specified from command line, use it instead of the base directory
            var outputFolder = Path.Combine(Config.OutputFolder ?? Config.BaseDirectory ?? string.Empty, configModel.Destination ?? DocAsCode.Constants.DefaultMetadataOutputFolderName);
            var inputModel = new Microsoft.DocAsCode.Metadata.ManagedReference.ExtractMetadataInputModel
            {
                PreserveRawInlineComments = configModel?.Raw ?? false,
                ForceRebuild = configModel?.Force ?? false,
                ApiFolderName = string.Empty,
                FilterConfigFile = configModel?.FilterConfigFile,
            };

            var expandedFileMapping = GlobUtility.ExpandFileMapping(Config.BaseDirectory, projects);
            inputModel.Items = new Dictionary<string, List<string>>
            {
                [outputFolder] = expandedFileMapping.Items.SelectMany(s => s.Files).ToList(),
            };

            return inputModel;
        }
コード例 #8
0
        public ExtractMetadataWorker(ExtractMetadataInputModel input, bool rebuild, bool useCompatibilityFileName)
        {
            _rawInput                  = input;
            _validInput                = ValidateInput(input);
            _rebuild                   = rebuild;
            _shouldSkipMarkup          = input.ShouldSkipMarkup;
            _preserveRawInlineComments = input.PreserveRawInlineComments;
            if (input.FilterConfigFile != null)
            {
                _filterConfigFile = Path.GetFullPath(Path.Combine(EnvironmentContext.BaseDirectory, input.FilterConfigFile)).Normalize();
            }
            _useCompatibilityFileName = useCompatibilityFileName;

            _msbuildProperties = input.MSBuildProperties ?? new Dictionary <string, string>();
            if (!_msbuildProperties.ContainsKey("Configuration"))
            {
                _msbuildProperties["Configuration"] = "Release";
            }

            _workspace = new Lazy <MSBuildWorkspace>(() => MSBuildWorkspace.Create(_msbuildProperties));
        }
コード例 #9
0
ファイル: ExtractMetadataWorker.cs プロジェクト: runt18/docfx
        private static ExtractMetadataInputModel ValidateInput(ExtractMetadataInputModel input)
        {
            if (input == null)
            {
                return(null);
            }

            if (input.Items == null || input.Items.Count == 0)
            {
                Logger.Log(LogLevel.Warning, "No source project or file to process, exiting...");
                return(null);
            }

            var items = new Dictionary <string, List <string> >();

            // 1. Input file should exists
            foreach (var pair in input.Items)
            {
                if (string.IsNullOrWhiteSpace(pair.Key))
                {
                    var value = string.Join(", ", pair.Value);
                    Logger.Log(LogLevel.Warning, $"Empty folder name is found: '{pair.Key}': '{value}'. It is not supported, skipping.");
                    continue;
                }

                // HashSet to guarantee the input file path is unique
                HashSet <string> validFilePath = new HashSet <string>();
                foreach (var inputFilePath in pair.Value)
                {
                    if (!string.IsNullOrEmpty(inputFilePath))
                    {
                        if (File.Exists(inputFilePath))
                        {
                            if (IsSupported(inputFilePath))
                            {
                                var path = TypeForwardedToStringExtension.ToNormalizedFullPath(inputFilePath);
                                validFilePath.Add(path);
                            }
                            else
                            {
                                var value = string.Join(",", SupportedExtensions);
                                Logger.Log(LogLevel.Warning, $"File {inputFilePath} is not supported, supported file extension are: {value}. The file will be ignored.");
                            }
                        }
                        else
                        {
                            Logger.Log(LogLevel.Warning, $"File {inputFilePath} does not exist, will be ignored.");
                        }
                    }
                }

                if (validFilePath.Count > 0)
                {
                    items.Add(pair.Key, validFilePath.ToList());
                }
            }

            if (items.Count > 0)
            {
                var clone = input.Clone();
                clone.Items = items;
                return(clone);
            }
            else
            {
                return(null);
            }
        }
コード例 #10
0
ファイル: MetadataCommand.cs プロジェクト: vicancy/docfx
        private ExtractMetadataInputModel ConvertToInputModel(MetadataJsonItemConfig configModel)
        {
            var projects = configModel.Source;
            // If Root Output folder is specified from command line, use it instead of the base directory
            var outputFolder = Path.Combine(Config.OutputFolder ?? Config.BaseDirectory ?? string.Empty, configModel.Destination ?? DocAsCode.Constants.DefaultMetadataOutputFolderName);
            var inputModel = new ExtractMetadataInputModel
            {
                PreserveRawInlineComments = configModel?.Raw ?? false,
                ForceRebuild = configModel?.Force ?? false,
                ShouldSkipMarkup = configModel?.ShouldSkipMarkup ?? false,
                ApiFolderName = string.Empty,
                FilterConfigFile = configModel?.FilterConfigFile,
                UseCompatibilityFileName = configModel?.UseCompatibilityFileName ?? false,
            };

            var expandedFileMapping = GlobUtility.ExpandFileMapping(Config.BaseDirectory, projects);
            inputModel.Items = new Dictionary<string, List<string>>
            {
                [outputFolder] = expandedFileMapping.Items.SelectMany(s => s.Files).ToList(),
            };

            return inputModel;
        }