private void ResolveXmlnsDefinitions(ReferenceGroupContext sourceContext, AssemblyDefinition asmDef, string assembly) { ICollection <CustomAttribute> attributes = asmDef.CustomAttributes; if (attributes == null || attributes.Count == 0) { return; } BuildMultiMap <string, string> xmlnsDefs = new BuildMultiMap <string, string>(); sourceContext.SetValue(assembly, xmlnsDefs); foreach (CustomAttribute attribute in attributes) { if (String.Equals(attribute.AttributeType.Name, "XmlnsDefinitionAttribute", StringComparison.OrdinalIgnoreCase)) { ICollection <CustomAttributeArgument> args = attribute.ConstructorArguments; if (args != null && args.Count == 2) { string xmlValue = null; string clrValue = null; int count = 0; foreach (CustomAttributeArgument arg in args) { count++; if (String.Equals(arg.Type.FullName, "System.String", StringComparison.OrdinalIgnoreCase)) { if (count == 1) { xmlValue = arg.Value.ToString(); } else if (count == 2) { clrValue = arg.Value.ToString(); } } if (!String.IsNullOrEmpty(xmlValue) && !String.IsNullOrEmpty(clrValue)) { xmlnsDefs.Add(xmlValue, clrValue); } } } } } }
public void Add(ReferenceGroupContext groupContext) { BuildExceptions.NotNull(groupContext, "groupContext"); if (this.IsInitialized) { BuildContext context = this.Context; groupContext.Initialize(context); //context.GroupContexts.Add(groupContext); this.SetValue(groupContext.Id, groupContext); } _contexts.Add(groupContext); }
private void OnResolverItem(string keyword, XPathNavigator navigator) { ReferenceGroupContext groupContext = _context.GroupContexts[_group.Id] as ReferenceGroupContext; if (groupContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } ReferenceGroupContext sourceContext = groupContext; if (!String.IsNullOrEmpty(_sourceId)) { sourceContext = groupContext.Contexts[_sourceId] as ReferenceGroupContext; } if (sourceContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } string sandcastleDir = _context.SandcastleDirectory; XmlWriter writer = navigator.InsertAfter(); // For now, write the default... // <resolver type="Microsoft.Ddue.Tools.Reflection.AssemblyResolver" // assembly="%DXROOT%\ProductionTools\MRefBuilder.exe" use-gac="false" /> writer.WriteStartElement("resolver"); if (!String.IsNullOrEmpty(_assistComponents) && File.Exists(_assistComponents)) { writer.WriteAttributeString("type", "Microsoft.Ddue.Tools.Reflection.RedirectAssemblyResolver"); writer.WriteAttributeString("assembly", _assistComponents); writer.WriteAttributeString("use-gac", "false"); IList <DependencyItem> items = sourceContext.BindingRedirects; if (items != null && items.Count != 0) { writer.WriteStartElement("bindingRedirects"); for (int i = 0; i < items.Count; i++) { DependencyItem item = items[i]; if (item.IsRedirected) { writer.WriteStartElement("bindingRedirect"); string strongName = item.StrongName; if (String.IsNullOrEmpty(strongName)) { AssemblyDefinition itemAssembly = AssemblyDefinition.ReadAssembly( item.Location); strongName = itemAssembly.FullName; } writer.WriteAttributeString("from", item.RedirectStrongName); writer.WriteAttributeString("to", strongName); writer.WriteEndElement(); } } writer.WriteEndElement(); } IList <string> sources = sourceContext.BindingSources; if ((_bindingSources != null && _bindingSources.Count != 0) || (sources != null && sources.Count != 0)) { HashSet <string> bindingSourceSet = new HashSet <string>( StringComparer.OrdinalIgnoreCase); writer.WriteStartElement("bindingSources"); if (sources != null) { for (int i = 0; i < sources.Count; i++) { string source = sources[i]; if (String.IsNullOrEmpty(source) || !Directory.Exists(source)) { continue; } string finalDir = String.Copy(source); if (!finalDir.EndsWith("\\")) { finalDir += "\\"; } if (!bindingSourceSet.Contains(finalDir)) { writer.WriteStartElement("bindingSource"); writer.WriteAttributeString("path", source); writer.WriteEndElement(); bindingSourceSet.Add(finalDir); } } } if (_bindingSources != null) { for (int i = 0; i < _bindingSources.Count; i++) { string source = _bindingSources[i]; if (String.IsNullOrEmpty(source) || !Directory.Exists(source)) { continue; } string finalDir = String.Copy(source); if (!finalDir.EndsWith("\\")) { finalDir += "\\"; } if (!bindingSourceSet.Contains(finalDir)) { writer.WriteStartElement("bindingSource"); writer.WriteAttributeString("path", source); writer.WriteEndElement(); bindingSourceSet.Add(finalDir); } } } writer.WriteEndElement(); } } else { writer.WriteAttributeString("type", "Microsoft.Ddue.Tools.Reflection.AssemblyResolver"); writer.WriteAttributeString("assembly", Path.Combine(sandcastleDir, @"ProductionTools\MRefBuilder.exe")); writer.WriteAttributeString("use-gac", "false"); } writer.WriteEndElement(); writer.Close(); navigator.DeleteSelf(); }
private void OnPlatformItem(string keyword, XPathNavigator navigator) { ReferenceGroupContext groupContext = _context.GroupContexts[_group.Id] as ReferenceGroupContext; if (groupContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } ReferenceGroupContext sourceContext = groupContext; if (!String.IsNullOrEmpty(_sourceId)) { sourceContext = groupContext.Contexts[_sourceId] as ReferenceGroupContext; } if (sourceContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } BuildFramework framework = sourceContext.Framework; if (framework == null) { throw new BuildException("No valid framework is specified."); } // For Silverlight/Portable, we use the equivalent .NET Framework // version, since the current reflection tool does not directly // support Silverlight/Portable. BuildFrameworkKind kind = framework.FrameworkType.Kind; if (kind == BuildFrameworkKind.Silverlight || kind == BuildFrameworkKind.Portable) { int major = framework.Version.Major; BuildFramework netFramework = null; switch (major) { case 5: netFramework = BuildFrameworks.GetFramework( major, BuildFrameworkKind.DotNet); if (netFramework == null) { // If not found, we move a version down... major = major - 1; goto case 4; } break; case 4: netFramework = BuildFrameworks.GetFramework( major, BuildFrameworkKind.DotNet); if (netFramework == null) { // If not found, we move a version down... major = major - 1; goto case 3; } break; case 3: netFramework = BuildFrameworks.GetFramework( major, 5, BuildFrameworkKind.DotNet); if (netFramework == null) { netFramework = BuildFrameworks.GetFramework( major, BuildFrameworkKind.DotNet); } if (netFramework == null) { // If not found, we move a version down... major = major - 1; goto case 2; } break; case 2: netFramework = BuildFrameworks.GetFramework( major, BuildFrameworkKind.DotNet); break; default: throw new BuildException( "The specified Silverlight version is not supported."); } if (netFramework == null) { throw new BuildException( "The equivalent .NET Framework for the specified Silverlight version cannot be found."); } framework = netFramework; } else if (kind == BuildFrameworkKind.ScriptSharp) { int major = framework.Version.Major; BuildFramework netFramework = null; switch (major) { case 1: // The current v1.0 is released for .NET 4.0 netFramework = BuildFrameworks.GetFramework( 4, BuildFrameworkKind.DotNet); if (netFramework == null) { netFramework = BuildFrameworks.LatestFramework; } break; default: throw new BuildException( "The specified Silverlight version is not supported."); } if (netFramework == null) { throw new BuildException( "The equivalent .NET Framework for the specified Silverlight version cannot be found."); } framework = netFramework; } Version version = framework.Version; XmlWriter writer = navigator.InsertAfter(); // For now, write the default... // <platform version="2.0" // path="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\" /> writer.WriteStartElement("platform"); if (version.Major > 2) { writer.WriteAttributeString("version", "2.0"); if (version.Major == 3) { Version version2 = BuildFrameworks.GetVersion(2, -1, BuildFrameworkKind.DotNet); writer.WriteAttributeString("path", String.Format( @"%SystemRoot%\Microsoft.NET\Framework\v{0}\", version2.ToString(3))); } else { string assemPath = Path.GetFullPath( Environment.ExpandEnvironmentVariables(String.Format( @"%SystemRoot%\Microsoft.NET\Framework\{0}\", framework.Folder))); if (!Directory.Exists(assemPath)) { assemPath = framework.AssemblyDir; } writer.WriteAttributeString("path", assemPath); } } else { writer.WriteAttributeString("version", version.ToString(2)); writer.WriteAttributeString("path", String.Format( @"%SystemRoot%\Microsoft.NET\Framework\{0}\", framework.Folder)); } writer.WriteEndElement(); writer.Close(); navigator.DeleteSelf(); }
/// <summary> /// The creates the configuration information or settings required by the /// target component for the build process. /// </summary> /// <param name="group"> /// A build group, <see cref="BuildGroup"/>, representing the documentation /// target for configuration. /// </param> /// <param name="writer"> /// An <see cref="XmlWriter"/> object used to create one or more new /// child nodes at the end of the list of child nodes of the current node. /// </param> /// <returns> /// Returns <see langword="true"/> for a successful configuration; /// otherwise, it returns <see langword="false"/>. /// </returns> /// <remarks> /// The <see cref="XmlWriter"/> writer passed to this configuration object /// may be passed on to other configuration objects, so do not close or /// dispose it. /// </remarks> public override bool Configure(BuildGroup group, XmlWriter writer) { BuildExceptions.NotNull(group, "group"); BuildExceptions.NotNull(writer, "writer"); IBuildNamedList <BuildGroupContext> groupContexts = _context.GroupContexts; if (groupContexts == null || groupContexts.Count == 0) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } ReferenceGroupContext groupContext = groupContexts[group.Id] as ReferenceGroupContext; if (groupContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } if (!this.Enabled || !this.IsInitialized) { return(false); } BuildFramework framework = groupContext.Framework; BuildFrameworkKind kind = framework.FrameworkType.Kind; ReferenceEngineSettings referenceSettings = _settings.EngineSettings[ BuildEngineType.Reference] as ReferenceEngineSettings; BuildSpecialSdkType webSdkType = referenceSettings.WebMvcSdkType; writer.WriteStartElement("options"); // start - options writer.WriteAttributeString("locale", _settings.CultureInfo.Name.ToLower()); if (kind == BuildFrameworkKind.Silverlight) { writer.WriteAttributeString("version", "VS.95"); } else if (kind == BuildFrameworkKind.Compact) { // The framework 3.5 is the last version of Windows CE... writer.WriteAttributeString("version", "VS.90"); } if (webSdkType != BuildSpecialSdkType.Null && webSdkType != BuildSpecialSdkType.None) { switch (webSdkType.Value) { case 10: // ASP.NET MVC 1.0: Supported in .NET 3.5 writer.WriteAttributeString("mvcVersion", "VS.90"); break; case 20: // ASP.NET MVC 2.0: Supported in .NET 3.5 SP1 // This is currently the default documentation for // the ASP.NET MVC Framework... writer.WriteAttributeString("mvcVersion", ""); break; case 30: // ASP.NET MVC 3.0: Supported in .NET 4.0 writer.WriteAttributeString("mvcVersion", "VS.98"); break; case 40: // ASP.NET MVC 4.0: Supported in .NET 4.5 writer.WriteAttributeString("mvcVersion", "VS.108"); break; } } writer.WriteAttributeString("linkTarget", "_" + _format.ExternalLinkTarget.ToString().ToLower()); writer.WriteEndElement(); // end - options bool isEmbeddedGroup = false; bool frameworkAvailable = false; bool isEmbeddedScript = groupContext.IsEmbeddedGroup; string tempText = _context["$EmbeddedScriptSharp"]; if (!String.IsNullOrEmpty(tempText)) { isEmbeddedScript = Convert.ToBoolean(tempText); } List <DataSource> dataSources = new List <DataSource>(); if (kind == BuildFrameworkKind.Silverlight) { string silverlightDir = groupContext["$SilverlightDataDir"]; if (!String.IsNullOrEmpty(silverlightDir) && Directory.Exists(silverlightDir)) { frameworkAvailable = true; writer.WriteStartElement("targets"); writer.WriteAttributeString("base", silverlightDir); writer.WriteAttributeString("recurse", "false"); writer.WriteAttributeString("system", "true"); writer.WriteAttributeString("files", "*.xml"); writer.WriteAttributeString("type", _format.ExternalLinkType.ToString().ToLower()); // Write the data source... Version latestVersion = BuildFrameworks.LatestSilverlightVersion; if (latestVersion == null) { latestVersion = framework.Version; } this.WriteDataSource(writer, DataSourceType.Silverlight, silverlightDir, latestVersion, true, true, dataSources); writer.WriteEndElement(); } } else if (kind == BuildFrameworkKind.Portable) { string portableDir = groupContext["$PortableDataDir"]; if (!String.IsNullOrEmpty(portableDir) && Directory.Exists(portableDir)) { frameworkAvailable = true; writer.WriteStartElement("targets"); writer.WriteAttributeString("base", portableDir); writer.WriteAttributeString("recurse", "false"); writer.WriteAttributeString("system", "true"); writer.WriteAttributeString("files", "*.xml"); writer.WriteAttributeString("type", _format.ExternalLinkType.ToString().ToLower()); // Write the data source... Version latestVersion = BuildFrameworks.LatestPortableVersion; if (latestVersion == null) { latestVersion = framework.Version; } this.WriteDataSource(writer, DataSourceType.Portable, portableDir, latestVersion, true, false, dataSources); writer.WriteEndElement(); } } else if (kind == BuildFrameworkKind.ScriptSharp) { string scriptSharpDir = groupContext["$ScriptSharpDataDir"]; if (!String.IsNullOrEmpty(scriptSharpDir) && Directory.Exists(scriptSharpDir)) { frameworkAvailable = true; if (!isEmbeddedGroup) { writer.WriteStartElement("targets"); writer.WriteAttributeString("base", scriptSharpDir); writer.WriteAttributeString("recurse", "false"); writer.WriteAttributeString("system", "true"); writer.WriteAttributeString("files", "*.xml"); if (isEmbeddedScript) { writer.WriteAttributeString("type", BuildLinkType.Local.ToString().ToLower()); } else { writer.WriteAttributeString("type", BuildLinkType.None.ToString().ToLower()); } // Write the data source... Version latestVersion = BuildFrameworks.LatestScriptSharpVersion; if (latestVersion == null) { latestVersion = framework.Version; } this.WriteDataSource(writer, DataSourceType.ScriptSharp, scriptSharpDir, latestVersion, true, false, dataSources); writer.WriteEndElement(); } } } // If not specialized framework, then write the default... if (!frameworkAvailable || kind == BuildFrameworkKind.None || kind == BuildFrameworkKind.DotNet || kind == BuildFrameworkKind.Compact) { string dotNetDataDir = Path.GetFullPath( Environment.ExpandEnvironmentVariables(ReferenceEngine.ReflectionDirectory)); writer.WriteStartElement("targets"); writer.WriteAttributeString("base", dotNetDataDir); writer.WriteAttributeString("recurse", "true"); writer.WriteAttributeString("system", "true"); writer.WriteAttributeString("files", "*.xml"); writer.WriteAttributeString("type", _format.ExternalLinkType.ToString().ToLower()); // Write the data source... this.WriteDataSource(writer, DataSourceType.Framework, dotNetDataDir, ReferenceEngine.ReflectionVersion, true, false, dataSources); writer.WriteEndElement(); } // The Portable and ScriptSharp do not support Blend... if (kind != BuildFrameworkKind.Portable && kind != BuildFrameworkKind.Compact && kind != BuildFrameworkKind.ScriptSharp) { string blendDir = groupContext["$BlendDataDir"]; if (!String.IsNullOrEmpty(blendDir) && Directory.Exists(blendDir)) { writer.WriteStartElement("targets"); writer.WriteAttributeString("base", blendDir); writer.WriteAttributeString("recurse", "false"); writer.WriteAttributeString("system", "true"); writer.WriteAttributeString("files", "*.xml"); writer.WriteAttributeString("type", _format.ExternalLinkType.ToString().ToLower()); // Write the data source... BuildSpecialSdk latestBlendSdk = null; if (kind == BuildFrameworkKind.Silverlight) { latestBlendSdk = BuildSpecialSdks.LatestBlendSilverlightSdk; } else { latestBlendSdk = BuildSpecialSdks.LatestBlendWpfSdk; } Version latestVersion = (latestBlendSdk == null) ? null : latestBlendSdk.Version; if (latestVersion == null) { latestVersion = framework.Version; } this.WriteDataSource(writer, DataSourceType.Blend, blendDir, latestVersion, true, kind == BuildFrameworkKind.Silverlight, dataSources); writer.WriteEndElement(); } } IList <string> linkDirs = _context.GetValue( "$ReferenceLinkDirectories") as IList <string>; IList <ReferenceLinkSource> linkSources = _context.GetValue( "$ReferenceLinkSources") as IList <ReferenceLinkSource>; if ((linkDirs != null && linkDirs.Count != 0) && (linkSources != null && linkSources.Count == linkDirs.Count)) { for (int i = 0; i < linkDirs.Count; i++) { ReferenceLinkSource linkSource = linkSources[i]; BuildLinkType sourceLinkType = linkSource.LinkType; writer.WriteStartElement("targets"); writer.WriteAttributeString("base", linkDirs[i]); writer.WriteAttributeString("recurse", "true"); writer.WriteAttributeString("system", "false"); writer.WriteAttributeString("files", "*.xml"); writer.WriteAttributeString("type", sourceLinkType.ToString().ToLower()); writer.WriteEndElement(); } } BuildLinkType linkType = _format.LinkType; string linkTypeText = linkType.ToString().ToLower(); // For the embedded group, we will not link to the other groups... if (!isEmbeddedGroup) { for (int i = 0; i < groupContexts.Count; i++) { ReferenceGroupContext aContext = groupContexts[i] as ReferenceGroupContext; if (aContext == null || aContext.IsLinkGroup) { continue; } if (aContext.GroupType != BuildGroupType.Reference || aContext == groupContext) { continue; } string linkFile = aContext["$ReflectionFile"]; if (!String.IsNullOrEmpty(linkFile)) { writer.WriteStartElement("targets"); writer.WriteAttributeString("base", @".\"); writer.WriteAttributeString("recurse", "false"); writer.WriteAttributeString("system", "false"); writer.WriteAttributeString("files", @".\" + linkFile); writer.WriteAttributeString("type", linkTypeText); writer.WriteEndElement(); } } } //<targets base=".\" recurse="false" // files=".\reflection.xml" type="local" /> writer.WriteStartElement("targets"); writer.WriteAttributeString("base", @".\"); writer.WriteAttributeString("recurse", "false"); writer.WriteAttributeString("system", "false"); writer.WriteAttributeString("files", @".\" + groupContext["$ReflectionFile"]); if (isEmbeddedGroup) { writer.WriteAttributeString("type", BuildLinkType.Local.ToString().ToLower()); } else { writer.WriteAttributeString("type", linkTypeText); } writer.WriteEndElement(); // Provide the information for the MSDN link resolvers... writer.WriteStartElement("linkResolver"); // start - linkResolver writer.WriteAttributeString("storage", _linkStorage.ToString().ToLower()); writer.WriteAttributeString("cache", _cacheLinks ? "true" : "false"); if (dataSources != null && dataSources.Count != 0) { for (int i = 0; i < dataSources.Count; i++) { DataSource dataSource = dataSources[i]; this.WriteDataSource(writer, dataSource.SourceType, dataSource.InputDir, dataSource.Version, dataSource.IsDatabase, dataSource.IsSilverlight, true); } } writer.WriteEndElement(); // end - linkResolver // Finally, provide the information for the conceptual links // in reference documents, if any... bool hasConceptualContext = _settings.BuildConceptual; if (hasConceptualContext) { hasConceptualContext = false; for (int i = 0; i < groupContexts.Count; i++) { BuildGroupContext aContext = groupContexts[i]; if (aContext.GroupType == BuildGroupType.Conceptual) { hasConceptualContext = true; break; } } } if (hasConceptualContext) { ConceptualEngineSettings conceptualSettings = _settings.EngineSettings[ BuildEngineType.Conceptual] as ConceptualEngineSettings; Debug.Assert(conceptualSettings != null, "The settings does not include the reference engine settings."); if (conceptualSettings == null) { return(false); } ConceptualLinkConfiguration linkConfig = conceptualSettings.ConceptualLinks; Debug.Assert(linkConfig != null, "There is no conceptual link configuration available."); if (linkConfig == null) { return(false); } writer.WriteStartElement("conceptualLinks"); //start: conceptualLinks writer.WriteAttributeString("enabled", "true"); writer.WriteAttributeString("showText", linkConfig.ShowLinkText.ToString()); writer.WriteAttributeString("showBrokenLinkText", linkConfig.ShowBrokenLinkText.ToString()); writer.WriteAttributeString("type", linkTypeText); for (int i = 0; i < groupContexts.Count; i++) { BuildGroupContext aContext = groupContexts[i]; if (aContext.GroupType == BuildGroupType.Conceptual) { writer.WriteStartElement("conceptualTargets"); // start - conceptualTargets writer.WriteAttributeString("base", String.Format( @".\{0}", aContext["$DdueXmlCompDir"])); writer.WriteAttributeString("type", linkTypeText); writer.WriteEndElement(); // end - conceptualTargets } } writer.WriteEndElement(); //end: conceptualLinks } return(true); }
/// <summary> /// The creates the configuration information or settings required by the /// target component for the build process. /// </summary> /// <param name="group"> /// A build group, <see cref="BuildGroup"/>, representing the documentation /// target for configuration. /// </param> /// <param name="writer"> /// An <see cref="XmlWriter"/> object used to create one or more new /// child nodes at the end of the list of child nodes of the current node. /// </param> /// <returns> /// Returns <see langword="true"/> for a successful configuration; /// otherwise, it returns <see langword="false"/>. /// </returns> /// <remarks> /// The <see cref="XmlWriter"/> writer passed to this configuration object /// may be passed on to other configuration objects, so do not close or /// dispose it. /// </remarks> public override bool Configure(BuildGroup group, XmlWriter writer) { BuildExceptions.NotNull(group, "group"); BuildExceptions.NotNull(writer, "writer"); if (!this.Enabled || !this.IsInitialized) { return(false); } Debug.Assert(_settings != null, "The settings object is required."); if (_settings == null || _context == null) { return(false); } ReferenceGroup refGroup = group as ReferenceGroup; if (refGroup == null) { return(false); } ReferenceGroupContext theContext = _context.GroupContexts[group.Id] as ReferenceGroupContext; if (theContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } ReferenceVersionType versionType = refGroup.VersionType; bool isBasicVersion = versionType == ReferenceVersionType.Assembly || versionType == ReferenceVersionType.AssemblyAndFile; writer.WriteStartElement("versionInfo"); //start: versionInfo writer.WriteAttributeString("enabled", isBasicVersion.ToString()); writer.WriteAttributeString("type", versionType.ToString()); writer.WriteAttributeString("sourceFile", Path.Combine(_context.WorkingDirectory, theContext["$ReflectionFile"])); writer.WriteEndElement(); //end: versionInfo //NOTE: This is now handled by the ReferenceCommentVisitor... //if (_settings.BuildConceptual) //{ // IList<BuildGroupContext> groupContexts = _context.GroupContexts; // for (int i = 0; i < groupContexts.Count; i++) // { // BuildGroupContext groupContext = groupContexts[i]; // if (groupContext.GroupType == BuildGroupType.Conceptual) // { // writer.WriteStartElement("conceptualLinks"); //start: conceptualLinks // writer.WriteAttributeString("enabled", "true"); // writer.WriteEndElement(); //end: conceptualLinks // break; // } // } //} return(true); }
private void ResolveDependency(ReferenceGroupContext sourceContext, ReferenceContent referenceContent) { BuildContext context = this.Context; BuildLogger logger = context.Logger; BuildFramework framework = sourceContext.Framework; if (framework == null) { throw new BuildException("No valid framework is specified."); } DependencyContent dependencies = referenceContent.Dependencies; _resolveContent = new DependencyContent(); _listReference = new List <ReferenceItem>(); _dictionary = new Dictionary <string, bool>( StringComparer.OrdinalIgnoreCase); _dictDependency = new Dictionary <string, bool>( StringComparer.OrdinalIgnoreCase); _dictReference = new Dictionary <string, bool>( StringComparer.OrdinalIgnoreCase); if (dependencies != null && dependencies.Count != 0) { for (int i = 0; i < dependencies.Count; i++) { DependencyItem depItem = dependencies[i]; if (!depItem.IsEmpty) { _dictDependency[depItem.Location] = true; } } } // Index the reference items to prevent cross referencing... if (referenceContent != null && referenceContent.Count != 0) { for (int i = 0; i < referenceContent.Count; i++) { ReferenceItem refItem = referenceContent[i]; if (!refItem.IsEmpty && !refItem.IsCommentOnly) { string refAssembly = refItem.Assembly; if (!_dictReference.ContainsKey(refAssembly)) { _dictReference[refAssembly] = true; _listReference.Add(refItem); } } } } GeneralAssemblyResolver resolver = new GeneralAssemblyResolver(); // Add the reference item directories, the most likely place to // find the dependencies for (int i = 0; i < _listReference.Count; i++) { resolver.AddSearchDirectory( Path.GetDirectoryName(_listReference[i].Assembly)); } // Add specified dependency directories, if any... IList <BuildDirectoryPath> dependencyPaths = dependencies.Paths; if (dependencyPaths != null && dependencyPaths.Count != 0) { for (int i = 0; i < dependencyPaths.Count; i++) { BuildDirectoryPath dependencyPath = dependencyPaths[i]; if (dependencyPath.Exists) { resolver.AddSearchDirectory(dependencyPath); } } } Version version = framework.Version; // Add, for the Silverlight, known installation directories... BuildFrameworkKind frameworkKind = framework.FrameworkType.Kind; if (frameworkKind == BuildFrameworkKind.Silverlight) { resolver.UseGac = false; string programFiles = PathUtils.ProgramFiles32; string searchDir = Path.Combine(programFiles, @"Microsoft Silverlight\" + version.ToString()); if (Directory.Exists(searchDir)) { resolver.AddSearchDirectory(searchDir); } searchDir = Path.Combine(programFiles, @"Reference Assemblies\Microsoft\Framework\Silverlight\v" + version.ToString(2)); if (Directory.Exists(searchDir)) { resolver.AddSearchDirectory(searchDir); } else { if (version.Major == 5 && version.Minor > 0) { // For Silverlight 5.1, the assemblies are in different places... searchDir = Path.Combine(programFiles, @"Reference Assemblies\Microsoft\Framework\Silverlight\v5.0"); if (Directory.Exists(searchDir)) { resolver.AddSearchDirectory(searchDir); } } } searchDir = Path.Combine(programFiles, @"Microsoft SDKs\Silverlight\v" + version.ToString(2)); if (!Directory.Exists(searchDir)) { if (version.Major == 5 && version.Minor > 0) { // For Silverlight 5.1, the assemblies are in different places... searchDir = Path.Combine(programFiles, @"Microsoft SDKs\Silverlight\v5.0"); } } if (Directory.Exists(searchDir)) { resolver.AddSearchDirectory(searchDir); string tempDir = String.Copy(searchDir); searchDir = Path.Combine(tempDir, @"Libraries\Client"); if (Directory.Exists(searchDir)) { resolver.AddSearchDirectory(searchDir); } searchDir = Path.Combine(tempDir, @"Libraries\Server"); if (Directory.Exists(searchDir)) { resolver.AddSearchDirectory(searchDir); } } if (version.Major == 3) { // 3. The Expression 3.0 Blend SDK... string otherDir = Path.Combine(programFiles, @"Microsoft SDKs\Expression\Blend 3\Interactivity\Libraries\Silverlight"); if (Directory.Exists(otherDir)) { resolver.AddSearchDirectory(otherDir); } otherDir = Path.Combine(programFiles, @"Microsoft SDKs\Expression\Blend 3\Prototyping\Libraries\Silverlight"); if (Directory.Exists(otherDir)) { resolver.AddSearchDirectory(otherDir); } } else if (version.Major == 4) { // Consider the extension libraries... // 1. The RIA Services... string otherDir = Path.Combine(programFiles, @"Microsoft SDKs\RIA Services\v1.0\Libraries\Silverlight"); if (Directory.Exists(otherDir)) { resolver.AddSearchDirectory(otherDir); } // 2. For the Silverlight Toolkit... otherDir = Path.Combine(programFiles, @"Microsoft SDKs\Silverlight\v4.0\Toolkit"); if (Directory.Exists(otherDir)) { // Get the latest installed version... string[] dirs = Directory.GetDirectories(otherDir); if (dirs != null && dirs.Length != 0) { string dir = String.Empty; DateTime latestDt = DateTime.MinValue; for (int j = 0; j < dirs.Length; j++) { string latestDir = Path.GetFileName(dirs[j]); DateTime dt; if (DateTime.TryParse(latestDir, out dt)) { if (dt > latestDt) { latestDt = dt; dir = latestDir; } } } otherDir = Path.Combine(otherDir, dir + @"\Bin"); if (Directory.Exists(otherDir)) { resolver.AddSearchDirectory(otherDir); } } } // 3. The Expression 4.0 Blend SDK... otherDir = Path.Combine(programFiles, @"Microsoft SDKs\Expression\Blend\Silverlight\v4.0\Libraries"); if (Directory.Exists(otherDir)) { resolver.AddSearchDirectory(otherDir); } } else if (version.Major == 5) { // Consider the extension libraries... // 1. The RIA Services... string otherDir = Path.Combine(programFiles, @"Microsoft SDKs\RIA Services\v1.0\Libraries\Silverlight"); if (Directory.Exists(otherDir)) { resolver.AddSearchDirectory(otherDir); } // 2. For the Silverlight Toolkit... otherDir = Path.Combine(programFiles, @"Microsoft SDKs\Silverlight\v5.0\Toolkit"); if (Directory.Exists(otherDir)) { // Get the latest installed version... string[] dirs = Directory.GetDirectories(otherDir); if (dirs != null && dirs.Length != 0) { string dir = String.Empty; DateTime latestDt = DateTime.MinValue; for (int j = 0; j < dirs.Length; j++) { string latestDir = Path.GetFileName(dirs[j]); DateTime dt; if (DateTime.TryParse(latestDir, out dt)) { if (dt > latestDt) { latestDt = dt; dir = latestDir; } } } otherDir = Path.Combine(otherDir, dir + @"\Bin"); if (Directory.Exists(otherDir)) { resolver.AddSearchDirectory(otherDir); } } } // 3. The Expression 5.0 Blend SDK... otherDir = Path.Combine(programFiles, @"Microsoft SDKs\Expression\Blend\Silverlight\v5.0\Libraries"); if (Directory.Exists(otherDir)) { resolver.AddSearchDirectory(otherDir); } } } else if (frameworkKind == BuildFrameworkKind.Portable) { resolver.UseGac = false; resolver.AddSearchDirectory(framework.AssemblyDir); } else if (frameworkKind == BuildFrameworkKind.ScriptSharp) { resolver.UseGac = false; resolver.AddSearchDirectory(framework.AssemblyDir); } else if (frameworkKind == BuildFrameworkKind.Compact) { resolver.UseGac = false; resolver.AddSearchDirectory(framework.AssemblyDir); } else if (frameworkKind == BuildFrameworkKind.DotNet) { string programFiles = Environment.GetFolderPath( Environment.SpecialFolder.ProgramFiles); if (version.Major == 3) { // 3. The Expression 3.0 Blend SDK... string otherDir = Path.Combine(programFiles, @"Microsoft SDKs\Expression\Blend 3\Interactivity\Libraries\.NETFramework"); if (Directory.Exists(otherDir)) { resolver.AddSearchDirectory(otherDir); } } else if (version.Major == 4) { string otherDir = Path.Combine(programFiles, @"Microsoft SDKs\Expression\Blend\.NETFramework\v4.0\Libraries"); if (Directory.Exists(otherDir)) { resolver.AddSearchDirectory(otherDir); } } } else { throw new NotSupportedException(String.Format( "The framework kind '{0}' is not supported.", frameworkKind.ToString())); } // Finally, we look inside the binding sources if we are dealing // with link sources... if (sourceContext.IsLinkGroup || sourceContext.IsEmbeddedGroup) { IList <string> bindingSources = sourceContext.BindingSources; if (bindingSources != null && bindingSources.Count != 0) { foreach (string bindingSource in bindingSources) { if (!String.IsNullOrEmpty(bindingSource) && Directory.Exists(bindingSource)) { resolver.AddSearchDirectory(bindingSource); } } } } for (int i = 0; i < _listReference.Count; i++) { ReferenceItem refItem = _listReference[i]; AssemblyDefinition asmDef = AssemblyDefinition.ReadAssembly( refItem.Assembly); ModuleDefinition modDef = asmDef.MainModule; // Try resolving all the dependencies... if (modDef.HasAssemblyReferences) { IList <AssemblyNameReference> asmRefs = modDef.AssemblyReferences; if (asmRefs != null && asmRefs.Count != 0) { for (int j = 0; j < asmRefs.Count; j++) { this.Resolve(logger, asmRefs[j], resolver, frameworkKind); } } } // Try resolving all the XmlnsDefinitionAttribute attributes... if (asmDef.HasCustomAttributes && refItem.XamlSyntax) { this.ResolveXmlnsDefinitions(sourceContext, asmDef, modDef.Name); } } string[] searchDirs = resolver.GetSearchDirectories(); if (searchDirs != null && searchDirs.Length != 0) { if (_searchDirectories == null) { _searchDirectories = new HashSet <string>(StringComparer.OrdinalIgnoreCase); } for (int i = 0; i < searchDirs.Length; i++) { string searchDir = Path.GetFullPath(String.Copy(searchDirs[i])); if (!searchDir.EndsWith("\\")) { searchDir += "\\"; } _searchDirectories.Add(searchDir); } } }
/// <summary> /// Applies the processing operations defined by this visitor to the /// specified reference group. /// </summary> /// <param name="group"> /// The <see cref="ReferenceGroup">reference group</see> to which the processing /// operations defined by this visitor will be applied. /// </param> /// <exception cref="ArgumentNullException"> /// If the <paramref name="group"/> is <see langword="null"/>. /// </exception> protected override void OnVisit(ReferenceGroup group) { BuildExceptions.NotNull(group, "group"); if (!this.IsInitialized) { throw new BuildException( "ReferenceProjectVisitor: The reference dependency resolver is not initialized."); } BuildContext context = this.Context; BuildLogger logger = context.Logger; if (logger != null) { logger.WriteLine("Begin - Resolving reference dependencies.", BuildLoggerLevel.Info); } ReferenceGroupContext groupContext = context.GroupContexts[group.Id] as ReferenceGroupContext; if (groupContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } ReferenceGroupContext sourceContext = groupContext; if (!String.IsNullOrEmpty(_sourceId)) { sourceContext = groupContext.Contexts[_sourceId] as ReferenceGroupContext; } if (sourceContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } _linkCommentFiles = new List <string>(); _bindingRedirects = new List <DependencyItem>(); _searchDirectories = new HashSet <string>(StringComparer.OrdinalIgnoreCase); sourceContext.LinkCommentFiles = _linkCommentFiles; sourceContext.BindingRedirects = _bindingRedirects; // We add the comment files from the link sources so that the // document can contain comments from these sources if needed... IList <ReferenceLinkSource> linkSources = context.GetValue("$ReferenceLinkSources") as IList <ReferenceLinkSource>; if (linkSources != null && linkSources.Count != 0) { for (int i = 0; i < linkSources.Count; i++) { ReferenceLinkSource linkSource = linkSources[i]; IEnumerable <ReferenceItem> linkItems = linkSource.Items; foreach (ReferenceItem linkItem in linkItems) { // Set if the comment file exists and link it... BuildFilePath linkCommentPath = linkItem.Comments; if (linkCommentPath != null && linkCommentPath.Exists) { _linkCommentFiles.Add(linkCommentPath.Path); } else { string linkCommentFile = Path.ChangeExtension( linkItem.Assembly, ".xml"); if (File.Exists(linkCommentFile)) { _linkCommentFiles.Add(linkCommentFile); } } } } } string dependencyDir = sourceContext.DependencyDir; string searchDir = String.Copy(dependencyDir); if (!searchDir.EndsWith("\\")) { searchDir += "\\"; } _searchDirectories.Add(searchDir); ReferenceContent content = _content; if (content == null) { content = group.Content; } DependencyContent dependencies = content.Dependencies; _dependencyContent = dependencies; this.ResolveDependency(sourceContext, content); if (_dependencyContent != null && _dependencyContent.Count != 0) { this.CreateDependency(_dependencyContent, dependencyDir); } if (_resolveContent != null && _resolveContent.Count != 0) { this.CreateDependency(_resolveContent, dependencyDir); } //IList<string> bindingSources = sourceContext.BindingSources; //if (bindingSources == null) //{ // bindingSources = new BuildList<string>(); // sourceContext.BindingSources = bindingSources; //} //foreach (string dir in _searchDirectories) //{ // bindingSources.Add(dir); //} if (logger != null) { logger.WriteLine("Completed - Resolving reference dependencies.", BuildLoggerLevel.Info); } }
public override void Initialize(BuildContext context, ReferenceGroup group) { base.Initialize(context, group); if (!this.IsInitialized) { return; } _notApplicable = false; context["$TocExcludedNamespaces"] = String.Empty; if (_tocExclude == null) { ReferenceEngineSettings engineSettings = this.EngineSettings; Debug.Assert(engineSettings != null); if (engineSettings == null) { this.IsInitialized = false; return; } _tocExclude = engineSettings.TocExclude; Debug.Assert(_tocExclude != null); if (_tocExclude == null) { this.IsInitialized = false; return; } } ReferenceGroupContext groupContext = context.GroupContexts[group.Id] as ReferenceGroupContext; if (groupContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } // We do not have to spell check embedded documents... string embeddedText = groupContext["$IsEmbeddedGroup"]; if (!String.IsNullOrEmpty(embeddedText) && embeddedText.Equals(Boolean.TrueString, StringComparison.OrdinalIgnoreCase)) { _notApplicable = true; return; } IList <string> commentFiles = groupContext.CommentFiles; if (commentFiles != null && commentFiles.Count != 0) { _listTocExcludes = new BuildList <string>(); for (int i = 0; i < commentFiles.Count; i++) { XPathDocument document = new XPathDocument(commentFiles[i]); XPathNavigator documentNavigator = document.CreateNavigator(); XPathNodeIterator iterator = documentNavigator.Select( "//member[.//tocexclude or .//excludetoc]/@name"); if (iterator != null && iterator.Count != 0) { foreach (XPathNavigator navigator in iterator) { _listTocExcludes.Add(navigator.Value); } } } if (_listTocExcludes.Count == 0) { this.IsInitialized = false; return; } } else { this.IsInitialized = false; return; } }
private void CreateLinkGroups(BuildContext context) { context["$EmbeddedScriptSharp"] = Boolean.FalseString; if (_listGroups == null || _listGroups.Count == 0) { return; } BuildLogger logger = context.Logger; List <ReferenceGroup> buildGroups = new List <ReferenceGroup>(); IList <BuildGroupContext> groupContexts = context.GroupContexts; bool hasScriptSharp = false; BuildFrameworkType latestScriptSharp = BuildFrameworkType.None; int itemCount = _listGroups.Count; int index = 0; for (int i = 0; i < itemCount; i++) { ReferenceGroup group = _listGroups[i]; ReferenceContent content = group.Content; if (content != null) { BuildFrameworkType frameworkType = content.FrameworkType; if (frameworkType.Kind == BuildFrameworkKind.ScriptSharp) { hasScriptSharp = true; if (frameworkType > latestScriptSharp) { latestScriptSharp = frameworkType; } } } } // Include contents from the Script# framework for correct // linking, since there is MSDN links for the Script#... if (hasScriptSharp && _engineSettings.EmbedScriptSharpFramework && latestScriptSharp.Kind == BuildFrameworkKind.ScriptSharp) { BuildFramework framework = BuildFrameworks.GetFramework(latestScriptSharp); if (framework == null) { framework = BuildFrameworks.LatestScriptSharp; } if (framework != null) { ReferenceGroup buildGroup = new ReferenceGroup( "Embedded ScriptSharp - " + ReferenceGroup.NextGroupName(), Guid.NewGuid().ToString()); ReferenceContent content = buildGroup.Content; string[] assemblies = Directory.GetFiles(framework.AssemblyDir, "*.dll", SearchOption.AllDirectories); for (int i = 0; i < assemblies.Length; i++) { string assembly = assemblies[i]; string comments = Path.ChangeExtension(assembly, ".xml"); if (File.Exists(comments)) { content.AddItem(comments, assembly); } } buildGroup.ExcludeToc = true; buildGroup.SyntaxType = BuildSyntaxType.CSharp | BuildSyntaxType.JavaScript; buildGroups.Add(buildGroup); // Create the group context... ReferenceGroupContext buildGroupContext = new ReferenceGroupContext(buildGroup); buildGroupContext.IsEmbeddedGroup = true; groupContexts.Add(buildGroupContext); string indexText = (itemCount + index + 1).ToString(); // Create the build dynamic properties... buildGroupContext.CreateProperties(indexText); // This has no effect, since the newly created group will // not have any content source. buildGroup.BeginSources(context); context["$EmbeddedScriptSharp"] = Boolean.TrueString; } } if (buildGroups.Count != 0) { _listGroups.Add(buildGroups); } // Process the user-provided link sources... List <ReferenceLinkSource> linkSources = null; IList <ReferenceLinkSource> listSources = _engineSettings.LinkSources as IList <ReferenceLinkSource>; if (listSources != null && listSources.Count != 0) { for (int i = 0; i < listSources.Count; i++) { ReferenceLinkSource linkSource = listSources[i]; if (linkSource == null || !linkSource.IsValid) { if (logger != null) { string title = linkSource.Title; if (title == null) { title = String.Empty; } logger.WriteLine(String.Format( "A provided reference link source titled = '{0}', at index = '{1}' is invalid.", title, i), BuildLoggerLevel.Warn); } continue; } if (linkSources == null) { linkSources = new List <ReferenceLinkSource>(); } linkSources.Add(linkSource); } } // Process the automatic link sources... BuildSpecialSdkType webMvcSdkType = _engineSettings.WebMvcSdkType; if (webMvcSdkType != BuildSpecialSdkType.None && webMvcSdkType != BuildSpecialSdkType.Null) { BuildSpecialSdk webSdk = BuildSpecialSdks.GetSdk(webMvcSdkType, BuildFrameworkKind.DotNet); if (webSdk != null) { ReferenceLinkSource linkSource = new ReferenceLinkSource(); linkSource.LinkType = BuildLinkType.Msdn; linkSource.Title = webMvcSdkType.Label; linkSource.FrameworkType = BuildFrameworks.LatestFramework.FrameworkType; string aspMVCDir = webSdk.AssemblyDir; string[] assemblyFiles = Directory.GetFiles( webSdk.AssemblyDir, "*.dll", SearchOption.TopDirectoryOnly); for (int i = 0; i < assemblyFiles.Length; i++) { string assemblyFile = assemblyFiles[i]; string commentFile = Path.ChangeExtension(assemblyFile, ".xml"); if (File.Exists(commentFile)) { ReferenceItem refItem = new ReferenceItem( commentFile, assemblyFile); refItem.XamlSyntax = false; linkSource.Add(refItem); } } if (linkSource.IsValid) { if (linkSources == null) { linkSources = new List <ReferenceLinkSource>(); } linkSources.Add(linkSource); } } } if (linkSources != null && linkSources.Count != 0) { context.SetValue("$ReferenceLinkSources", linkSources); itemCount = linkSources.Count; if (_linkGroups == null) { _linkGroups = new BuildList <ReferenceGroup>(); } for (int i = 0; i < itemCount; i++) { ReferenceLinkSource linkSource = linkSources[i]; ReferenceGroup linkGroup = new ReferenceGroup( "Reference Links - " + ReferenceGroup.NextGroupName(), linkSource.SourceId, linkSource); linkGroup.ExcludeToc = true; _linkGroups.Add(linkGroup); // Create the group context... ReferenceGroupContext linkGroupContext = new ReferenceGroupContext(linkGroup); linkGroupContext.IsLinkGroup = true; groupContexts.Add(linkGroupContext); string indexText = String.Empty; if (itemCount > 1) { indexText = (i + 1).ToString(); } // Create the build dynamic properties... linkGroupContext.CreateProperties(indexText); // This has no effect, since the newly created group will // not have any content source. linkGroup.BeginSources(context); } } }
private void CreateReflectionSteps(BuildMultiStep listSteps, ReferenceGroup group, string sandcastleDir, string helpStyle) { Debug.Assert(_engineSettings != null); if (_engineSettings == null) { return; } BuildContext context = this.Context; BuildSettings settings = this.Settings; ReferenceGroupContext groupContext = context.GroupContexts[group.Id] as ReferenceGroupContext; if (groupContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } string workingDir = context.WorkingDirectory; ReferenceContent content = group.Content; string assemblyDir = Path.Combine(workingDir, groupContext.AssemblyFolder); string dependencyDir = Path.Combine(workingDir, groupContext.DependencyFolder); DependencyContent dependencies = content.Dependencies; string reflectionFile = groupContext["$ReflectionFile"]; string manifestFile = groupContext["$ManifestFile"]; string refBuilderFile = groupContext["$ReflectionBuilderFile"]; string tocFile = groupContext["$TocFile"]; BuildStyleType outputStyle = settings.Style.StyleType; string tempText = null; string arguments = null; string application = null; bool ripOldApis = true; string assemblyFiles = null; string dependencyFiles = null; string outputFile = null; string configurationFile = null; ReferenceVisibilityConfiguration visibility = _engineSettings.Visibility; Debug.Assert(visibility != null); // 1. Create the reflection and the manifest StringBuilder textBuilder = new StringBuilder(); if (group.IsSingleVersion) { // Call MRefBuilder to generate the reflection... // MRefBuilder Assembly.dll // /out:reflection.org /config:MRefBuilder.config // /internal- application = Path.Combine(context.SandcastleToolsDirectory, "MRefBuilder.exe"); assemblyFiles = String.Format(@"{0}\*.*", assemblyDir); dependencyFiles = String.Format(@"{0}\*.*", dependencyDir); outputFile = Path.ChangeExtension(reflectionFile, ".ver"); configurationFile = Path.Combine(workingDir, refBuilderFile); textBuilder.Append(assemblyFiles); textBuilder.Append(" /dep:" + dependencyFiles); textBuilder.AppendFormat(" /out:{0} /config:{1}", outputFile, refBuilderFile); if (visibility != null && visibility.IncludeInternalsMembers) { textBuilder.Append(" /internal+"); } else { textBuilder.Append(" /internal-"); } arguments = textBuilder.ToString(); outputFile = Path.Combine(workingDir, outputFile); } else { // Call the VersionBuilder to create the combined reflection file... application = Path.Combine(context.SandcastleToolsDirectory, "VersionBuilder.exe"); textBuilder.AppendFormat(" /config:{0} /out:{1}", groupContext["$ApiVersionsBuilderFile"], Path.ChangeExtension(reflectionFile, ".org")); configurationFile = Path.Combine(workingDir, groupContext["$ApiVersionsBuilderFile"]); ReferenceVersionInfo versionInfo = group.VersionInfo; ripOldApis = versionInfo.RipOldApis; if (ripOldApis) { textBuilder.Append(" /rip+"); } else { textBuilder.Append(" /rip-"); } arguments = textBuilder.ToString(); } StepReflectionBuilder refBuilder = new StepReflectionBuilder(workingDir, application, arguments); refBuilder.Group = group; refBuilder.LogTitle = String.Empty; refBuilder.Message = "Creating XML-formatted reflection information."; refBuilder.CopyrightNotice = 2; // For the direct use of the Sandcastle library, we need the // following parameters... refBuilder.RipOldApis = ripOldApis; refBuilder.DocumentInternals = (visibility != null && visibility.IncludeInternalsMembers); refBuilder.ConfigurationFile = configurationFile; refBuilder.ReflectionFile = outputFile; refBuilder.AssemblyFiles.Add(assemblyFiles); refBuilder.DependencyFiles.Add(dependencyFiles); listSteps.Add(refBuilder); textBuilder.Length = 0; // 2. Create the reflection and comment refining step... StepReferenceRefine referenceRefine = new StepReferenceRefine(workingDir); referenceRefine.LogTitle = String.Empty; referenceRefine.Message = "Refining the reflection files - filtering and cleaning"; referenceRefine.Group = group; listSteps.Add(referenceRefine); textBuilder.Length = 0; // 3. Apply Transforms // XslTransform.exe // /xsl:"%DXROOT%\ProductionTransforms\ApplyVSDocModel.xsl" // reflection.org // /xsl:"%DXROOT%\ProductionTransforms\AddFriendlyFilenames.xsl" // /out:reflection.xml /arg:IncludeAllMembersTopic=true // /arg:IncludeInheritedOverloadTopics=true /arg:project=Project application = Path.Combine(context.SandcastleToolsDirectory, "XslTransform.exe"); string prodPath = Path.Combine(sandcastleDir, "ProductionTransforms"); string textTemp = String.Empty; if (group.EnableXmlnsForXaml) { textTemp = Path.Combine(prodPath, "AddXamlSyntaxData.xsl"); if (!String.IsNullOrEmpty(textTemp)) { textBuilder.AppendFormat(" /xsl:\"{0}\"", textTemp); textTemp = String.Empty; } } if (outputStyle == BuildStyleType.ClassicWhite || outputStyle == BuildStyleType.ClassicBlue) { textTemp = Path.Combine(prodPath, "ApplyVSDocModel.xsl"); } else if (outputStyle == BuildStyleType.Lightweight) { } else if (outputStyle == BuildStyleType.ScriptFree) { } if (!String.IsNullOrEmpty(textTemp)) { textBuilder.AppendFormat(" /xsl:\"{0}\"", textTemp); textTemp = String.Empty; } ReferenceNamingMethod namingMethod = _engineSettings.Naming; if (namingMethod == ReferenceNamingMethod.Guid) { textTemp = Path.Combine(prodPath, "AddGuidFilenames.xsl"); } else if (namingMethod == ReferenceNamingMethod.MemberName) { textTemp = Path.Combine(prodPath, "AddFriendlyFilenames.xsl"); } else { textTemp = Path.Combine(prodPath, "AddGuidFilenames.xsl"); } if (!String.IsNullOrEmpty(textTemp)) { textBuilder.AppendFormat(" /xsl:\"{0}\"", textTemp); textTemp = String.Empty; } textBuilder.Append(" " + Path.ChangeExtension(reflectionFile, ".org")); textBuilder.AppendFormat(" /out:{0}", reflectionFile); textBuilder.AppendFormat(" /arg:IncludeAllMembersTopic={0}", _engineSettings.IncludeAllMembersTopic ? "true" : "false"); textBuilder.AppendFormat(" /arg:IncludeInheritedOverloadTopics={0}", _engineSettings.IncludeInheritedOverloadTopics ? "true" : "false"); bool rootContainer = _engineSettings.RootNamespaceContainer; string rootTitle = group.RootNamespaceTitle; if (rootContainer && !String.IsNullOrEmpty(rootTitle)) { textBuilder.Append(" /arg:project=Project"); // Indicate that this reference group is rooted... groupContext["$IsRooted"] = Boolean.TrueString; } arguments = textBuilder.ToString(); StepReferenceModel applyDocProcess = new StepReferenceModel( workingDir, application, arguments); applyDocProcess.Group = group; applyDocProcess.LogTitle = String.Empty; applyDocProcess.Message = "Xsl Transformation - Applying model and adding filenames"; applyDocProcess.CopyrightNotice = 2; listSteps.Add(applyDocProcess); textBuilder.Length = 0; // 4. and finally the manifest... // XslTransform.exe // /xsl:"%DXROOT%\ProductionTransforms\ReflectionToManifest.xsl" // reflection.xml /out:manifest.xml application = Path.Combine(context.SandcastleToolsDirectory, "XslTransform.exe"); textTemp = Path.Combine(prodPath, "ReflectionToManifest.xsl"); textBuilder.AppendFormat(" /xsl:\"{0}\"", textTemp); textBuilder.AppendFormat(" {0} /out:{1}", reflectionFile, manifestFile); arguments = textBuilder.ToString(); StepReferenceManifest manifestProcess = new StepReferenceManifest( workingDir, application, arguments); manifestProcess.Group = group; manifestProcess.LogTitle = String.Empty; manifestProcess.Message = "Xsl Transformation - Reflection to Manifest"; manifestProcess.CopyrightNotice = 2; listSteps.Add(manifestProcess); // 5. Create the reflection table of contents // XslTransform.exe // /xsl:"%DXROOT%\ProductionTransforms\createvstoc.xsl" // reflection.xml /out:ApiToc.xml application = Path.Combine(context.SandcastleToolsDirectory, "XslTransform.exe"); if (outputStyle == BuildStyleType.ClassicWhite || outputStyle == BuildStyleType.ClassicBlue) { tempText = Path.Combine(sandcastleDir, @"ProductionTransforms\CreateVSToc.xsl"); } else if (outputStyle == BuildStyleType.Lightweight) { } else if (outputStyle == BuildStyleType.ScriptFree) { } arguments = String.Format("/xsl:\"{0}\" {1} /out:{2}", tempText, reflectionFile, tocFile); StepReferenceToc tocProcess = new StepReferenceToc(workingDir, application, arguments); tocProcess.LogTitle = String.Empty; tocProcess.Message = "Xsl Transformation - Creating References TOC"; tocProcess.Group = group; tocProcess.CopyrightNotice = 2; listSteps.Add(tocProcess); }
/// <summary> /// The creates the configuration information or settings required by the /// target component for the build process. /// </summary> /// <param name="group"> /// A build group, <see cref="BuildGroup"/>, representing the documentation /// target for configuration. /// </param> /// <param name="writer"> /// An <see cref="XmlWriter"/> object used to create one or more new /// child nodes at the end of the list of child nodes of the current node. /// </param> /// <returns> /// Returns <see langword="true"/> for a successful configuration; /// otherwise, it returns <see langword="false"/>. /// </returns> /// <remarks> /// The <see cref="XmlWriter"/> writer passed to this configuration object /// may be passed on to other configuration objects, so do not close or /// dispose it. /// </remarks> public override bool Configure(BuildGroup group, XmlWriter writer) { BuildExceptions.NotNull(group, "group"); BuildExceptions.NotNull(writer, "writer"); if (!this.Enabled || !this.IsInitialized) { return(false); } ReferenceGroup refGroup = group as ReferenceGroup; if (refGroup == null) { return(false); } ReferenceGroupContext theContext = _context.GroupContexts[group.Id] as ReferenceGroupContext; if (theContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } ReferenceVersionType versionType = refGroup.VersionType; if (versionType != ReferenceVersionType.Advanced) { return(false); } ReferenceVersionInfo versionInfo = refGroup.VersionInfo; if (versionInfo == null || versionInfo.IsEmpty || !versionInfo.PlatformFilters) { return(false); } IList <ReferenceVersions> platforms = theContext.Versions; if (platforms == null || platforms.Count == 0) { return(false); } //<component type="Microsoft.Ddue.Tools.PlatformsComponent" assembly="%DXROOT%\ProductionTools\BuildComponents.dll"> // <!-- The order of filter files in this config determines the order of platforms in the output. --> // <filter files=".\SupportFiles\Platforms\WinVista.xml"/> // <filter files=".\SupportFiles\Platforms\WinXP.xml"/> // <filter files=".\SupportFiles\Platforms\WinXpMediaCenter.xml"/> // <filter files=".\SupportFiles\Platforms\WinXPPro64.xml"/> // <filter files=".\SupportFiles\Platforms\WinXPSE.xml"/> // <filter files=".\SupportFiles\Platforms\WinSvr2003.xml"/> // <filter files=".\SupportFiles\Platforms\WinSvr2000.xml"/> // <filter files=".\SupportFiles\Platforms\WinME.xml"/> // <filter files=".\SupportFiles\Platforms\Win98.xml"/> // <filter files=".\SupportFiles\Platforms\WindowsCE.xml"/> // <filter files=".\SupportFiles\Platforms\SmartPhone.xml"/> // <filter files=".\SupportFiles\Platforms\PocketPC.xml"/> // <filter files=".\SupportFiles\Platforms\Xbox360.xml"/> //</component> writer.WriteComment(" The order of filter files in this config determines the order of platforms in the output. "); for (int i = 0; i < platforms.Count; i++) { ReferenceVersions platform = platforms[i]; string platformFile = platform.PlatformFile; if (String.IsNullOrEmpty(platformFile) || !File.Exists(platformFile)) { continue; } writer.WriteStartElement("filter"); //start: filter writer.WriteAttributeString("files", platformFile); writer.WriteEndElement(); //end: filter } return(true); }
private void OnReferenceContentsItem(string keyword, XPathNavigator navigator) { BuildContext context = this.Context; ReferenceGroupContext groupContext = context.GroupContexts[_group.Id] as ReferenceGroupContext; if (groupContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } BuildFramework framework = groupContext.Framework; if (framework == null) { throw new BuildException("No valid framework is specified."); } BuildFrameworkKind kind = framework.FrameworkType.Kind; //<data base="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\en\" // recurse="false" files="*.xml" /> //<data files=".\Comments\Project.xml" /> //<data files=".\Comments\TestLibrary.xml" /> XmlWriter writer = navigator.InsertAfter(); string warnOverride = "false"; BuildLoggerVerbosity loggerVerbosity = _settings.Logging.Verbosity; if (loggerVerbosity == BuildLoggerVerbosity.Detailed || loggerVerbosity == BuildLoggerVerbosity.Diagnostic || loggerVerbosity == BuildLoggerVerbosity.Normal) { warnOverride = "true"; } CultureInfo culture = _settings.CultureInfo; string langName = culture.TwoLetterISOLanguageName; IEnumerable <string> commentDirs = framework.CommentDirs; // Store all the framework directories here, we will use this to // eliminate adding comment files directly from these directories... HashSet <string> commentDirSet = new HashSet <string>( StringComparer.OrdinalIgnoreCase); if (commentDirs != null) { writer.WriteComment(" The following are the framework (.NET, Silverlight etc) comment file directories. "); if (kind == BuildFrameworkKind.Silverlight) { this.WriteDataSources(writer, DataSourceType.Silverlight, String.Empty, framework.Version, true, true, langName, commentDirs); } else if (kind == BuildFrameworkKind.Portable) { this.WriteDataSources(writer, DataSourceType.Portable, String.Empty, framework.Version, true, false, langName, commentDirs); } else if (kind == BuildFrameworkKind.ScriptSharp) { this.WriteDataSources(writer, DataSourceType.ScriptSharp, String.Empty, framework.Version, true, false, langName, commentDirs); } else if (kind == BuildFrameworkKind.Compact) { // For the compact framework, the comments files are all // redirected to the system comment files... BuildFramework latestFramework = BuildFrameworks.LatestFramework; commentDirs = latestFramework.CommentDirs; this.WriteDataSources(writer, DataSourceType.Framework, String.Empty, latestFramework.Version, true, false, langName, commentDirs); } else { // Write the data source... this.WriteDataSources(writer, DataSourceType.Framework, String.Empty, framework.Version, true, false, langName, commentDirs); } foreach (string commentDir in commentDirs) { if (!Directory.Exists(commentDir)) { continue; } string finalDir = null; string langDir = Path.Combine(commentDir, langName); writer.WriteStartElement("data"); // start - data if (Directory.Exists(langDir)) { writer.WriteAttributeString("base", langDir); finalDir = langDir; } else { writer.WriteAttributeString("base", commentDir); finalDir = commentDir; } writer.WriteAttributeString("recurse", "false"); writer.WriteAttributeString("system", "true"); writer.WriteAttributeString("warnOverride", warnOverride); writer.WriteAttributeString("files", "*.xml"); writer.WriteEndElement(); // end - data if (!finalDir.EndsWith("\\")) { finalDir += "\\"; } commentDirSet.Add(finalDir); } } IEnumerable <string> commentFiles = framework.CommentFiles; if (commentFiles != null) { writer.WriteComment(" The following are the framework (.NET, Silverlight etc) comment files. "); foreach (string commentFile in commentFiles) { // Try to avoid adding comment files from known framework // directories... string commentDir = Path.GetDirectoryName(commentFile); if (!commentDir.EndsWith("\\")) { commentDir += "\\"; } if (commentDirSet.Contains(commentDir)) { continue; } writer.WriteStartElement("data"); writer.WriteAttributeString("files", commentFile); writer.WriteAttributeString("warnOverride", "false"); writer.WriteEndElement(); } } IList <string> linkCommentFiles = groupContext.LinkCommentFiles; if (linkCommentFiles != null && linkCommentFiles.Count != 0) { writer.WriteComment(" The following are the dependent assembly comment files. "); for (int i = 0; i < linkCommentFiles.Count; i++) { string linkCommentFile = linkCommentFiles[i]; // Try to avoid adding comment files from known framework // directories... string commentDir = Path.GetDirectoryName(linkCommentFile); if (!commentDir.EndsWith("\\")) { commentDir += "\\"; } if (commentDirSet.Contains(commentDir)) { continue; } writer.WriteStartElement("data"); writer.WriteAttributeString("files", linkCommentFile); writer.WriteAttributeString("warnOverride", "false"); writer.WriteEndElement(); } } IList <string> targetCommentFiles = groupContext.CommentFiles; if (targetCommentFiles != null && targetCommentFiles.Count != 0) { writer.WriteComment(" The following are the target comment files. "); for (int i = 0; i < targetCommentFiles.Count; i++) { writer.WriteStartElement("data"); writer.WriteAttributeString("files", targetCommentFiles[i]); writer.WriteAttributeString("warnOverride", "false"); writer.WriteEndElement(); } } writer.Close(); navigator.DeleteSelf(); }
protected void OnReferenceDataItem(string keyword, XPathNavigator navigator) { BuildContext context = this.Context; IBuildNamedList <BuildGroupContext> groupContexts = context.GroupContexts; if (groupContexts == null || groupContexts.Count == 0) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } ReferenceGroupContext groupContext = groupContexts[_group.Id] as ReferenceGroupContext; if (groupContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } BuildFramework framework = groupContext.Framework; BuildFrameworkKind kind = framework.FrameworkType.Kind; string sandcastleDir = context.SandcastleDirectory; //<data base="%DXROOT%\Data\Reflection" recurse="true" files="*.xml" /> //<data files=".\reflection.xml" /> XmlWriter writer = navigator.InsertAfter(); // For now, lets simply write the default... bool dataAvailable = false; if (kind == BuildFrameworkKind.Silverlight) { string silverlightDir = groupContext["$SilverlightDataDir"]; if (!String.IsNullOrEmpty(silverlightDir) && Directory.Exists(silverlightDir)) { dataAvailable = true; writer.WriteStartElement("data"); // start - data writer.WriteAttributeString("base", silverlightDir); writer.WriteAttributeString("recurse", "true"); // Prevent warning, when the same namespace occurs in different // assemblies... writer.WriteAttributeString("warnOverride", "false"); writer.WriteAttributeString("files", "*.xml"); // Write the data source... Version latestVersion = BuildFrameworks.LatestSilverlightVersion; if (latestVersion == null) { latestVersion = framework.Version; } this.WriteDataSource(writer, DataSourceType.Silverlight, silverlightDir, latestVersion, true, true); writer.WriteEndElement(); // end - data } } else if (kind == BuildFrameworkKind.Portable) { string portableDir = groupContext["$PortableDataDir"]; if (!String.IsNullOrEmpty(portableDir) && Directory.Exists(portableDir)) { dataAvailable = true; writer.WriteStartElement("data"); // start - data writer.WriteAttributeString("base", portableDir); writer.WriteAttributeString("recurse", "true"); // Prevent warning, when the same namespace occurs in different // assemblies... writer.WriteAttributeString("warnOverride", "false"); writer.WriteAttributeString("files", "*.xml"); // Write the data source... Version latestVersion = BuildFrameworks.LatestPortableVersion; if (latestVersion == null) { latestVersion = framework.Version; } this.WriteDataSource(writer, DataSourceType.Portable, portableDir, latestVersion, true, false); writer.WriteEndElement(); // end - data } } else if (kind == BuildFrameworkKind.ScriptSharp) { string scriptSharpDir = groupContext["$ScriptSharpDataDir"]; if (!String.IsNullOrEmpty(scriptSharpDir) && Directory.Exists(scriptSharpDir)) { dataAvailable = true; if (!groupContext.IsEmbeddedGroup) { writer.WriteStartElement("data"); // start - data writer.WriteAttributeString("base", scriptSharpDir); writer.WriteAttributeString("recurse", "true"); // Prevent warning, when the same namespace occurs in different // assemblies... writer.WriteAttributeString("warnOverride", "false"); writer.WriteAttributeString("files", "*.xml"); // Write the data source... Version latestVersion = BuildFrameworks.LatestScriptSharpVersion; if (latestVersion == null) { latestVersion = framework.Version; } this.WriteDataSource(writer, DataSourceType.ScriptSharp, scriptSharpDir, latestVersion, true, false); writer.WriteEndElement(); // end - data } } } if (!dataAvailable || kind == BuildFrameworkKind.None || kind == BuildFrameworkKind.DotNet || kind == BuildFrameworkKind.Compact) { string dotNetDataDir = Path.GetFullPath( Environment.ExpandEnvironmentVariables(ReferenceEngine.ReflectionDirectory)); writer.WriteStartElement("data"); // start - data writer.WriteAttributeString("base", dotNetDataDir); writer.WriteAttributeString("recurse", "true"); // Prevent warning, when the same namespace occurs in different // assemblies... writer.WriteAttributeString("warnOverride", "false"); writer.WriteAttributeString("files", "*.xml"); // Write the data source... this.WriteDataSource(writer, DataSourceType.Framework, dotNetDataDir, ReferenceEngine.ReflectionVersion, true, false); writer.WriteEndElement(); // end - data } // The Portable and ScriptSharp do not support Blend... if (kind != BuildFrameworkKind.Portable && kind != BuildFrameworkKind.Compact && kind != BuildFrameworkKind.ScriptSharp) { string blendDir = groupContext["$BlendDataDir"]; if (!String.IsNullOrEmpty(blendDir) && Directory.Exists(blendDir)) { dataAvailable = true; writer.WriteStartElement("data"); // start - data writer.WriteAttributeString("base", blendDir); writer.WriteAttributeString("recurse", "true"); // Prevent warning, when the same namespace occurs in different // assemblies... writer.WriteAttributeString("warnOverride", "false"); writer.WriteAttributeString("files", "*.xml"); // Write the data source... BuildSpecialSdk latestBlendSdk = null; if (kind == BuildFrameworkKind.Silverlight) { latestBlendSdk = BuildSpecialSdks.LatestBlendSilverlightSdk; } else { latestBlendSdk = BuildSpecialSdks.LatestBlendWpfSdk; } Version latestVersion = (latestBlendSdk == null) ? null : latestBlendSdk.Version; if (latestVersion == null) { latestVersion = framework.Version; } this.WriteDataSource(writer, DataSourceType.Blend, blendDir, latestVersion, true, kind == BuildFrameworkKind.Silverlight); writer.WriteEndElement(); // end - data } } //IList<string> linkDirs = groupContext.LinkDirectories; //if (linkDirs != null && linkDirs.Count != 0) //{ // for (int i = 0; i < linkDirs.Count; i++) // { // writer.WriteStartElement("data"); // start - data // writer.WriteAttributeString("base", linkDirs[i]); // writer.WriteAttributeString("recurse", "true"); // // Prevent warning, when the same namespace occurs in different // // assemblies... // writer.WriteAttributeString("warnOverride", "false"); // writer.WriteAttributeString("files", "*.xml"); // writer.WriteEndElement(); // end - data // } //} writer.WriteStartElement("data"); // start - data writer.WriteAttributeString("files", String.Format(@".\{0}", groupContext["$ReflectionFile"])); writer.WriteEndElement(); // end - data writer.Close(); navigator.DeleteSelf(); }
public override BuildGroupContext Clone() { ReferenceGroupContext groupContext = new ReferenceGroupContext(this); return(groupContext); }
public ReferenceGroupContext(ReferenceGroupContext context) : base(context) { }