static partial void ImportLegacy_1_1(string legacyOptionsFileName, ref MDKProjectOptions options, string optionsFileName, ref MDKProjectPaths paths, string pathsFileName) { var scriptInfo = LegacyProjectScriptInfo_1_1.Load(legacyOptionsFileName); if (scriptInfo.IsValid) { options = MDKProjectOptions.Import(scriptInfo, optionsFileName); paths = MDKProjectPaths.Import(scriptInfo, pathsFileName); } }
#pragma warning disable RS1012 // Start action has no registered actions. bool LoadOptions(CompilationStartAnalysisContext context, AdditionalText mdkOptions) #pragma warning restore RS1012 // Start action has no registered actions. { try { var content = mdkOptions.GetText(context.CancellationToken); var properties = MDKProjectOptions.Parse(content.ToString(), mdkOptions.Path); var basePath = Path.GetFullPath(Path.GetDirectoryName(mdkOptions.Path) ?? ".").TrimEnd('\\') + "\\..\\"; if (!basePath.EndsWith("\\")) { basePath += "\\"; } _basePath = new Uri(basePath); _namespaceName = properties.Namespace ?? DefaultNamespaceName; lock (_ignoredFolders) lock (_ignoredFiles) { _ignoredFolders.Clear(); _ignoredFiles.Clear(); foreach (var folder in properties.IgnoredFolders) { if (!folder.EndsWith("\\")) { _ignoredFolders.Add(new Uri(_basePath, new Uri(folder + "\\", UriKind.RelativeOrAbsolute))); } else { _ignoredFolders.Add(new Uri(_basePath, new Uri(folder, UriKind.RelativeOrAbsolute))); } } foreach (var file in properties.IgnoredFiles) { _ignoredFiles.Add(new Uri(_basePath, new Uri(file, UriKind.RelativeOrAbsolute))); } } return(true); } catch (Exception) { return(false); } }
internal static MDKProjectOptions Import(MDKProjectProperties.LegacyProjectScriptInfo_1_1 scriptInfo, string optionsFileName) { if (!scriptInfo.IsValid) { return(null); } var options = new MDKProjectOptions(optionsFileName, true) { Minify = scriptInfo.Minify, TrimTypes = scriptInfo.TrimTypes }; foreach (var ignore in scriptInfo.IgnoredFiles) { options.IgnoredFiles.Add(ignore); } foreach (var ignore in scriptInfo.IgnoredFolders) { options.IgnoredFolders.Add(ignore); } options.Commit(); options.Version = scriptInfo.Version; return(options); }