/// <summary> /// Execute the task. /// </summary> /// <returns> /// <c>true</c>, if the task executed succesfully; otherwise, <c>false</c>. /// </returns> public override bool Execute() { FileInfo moduleAssemblyFile = new FileInfo( ModuleAssembly.GetMetadata("FullPath") ); Log.LogMessage(MessageImportance.Low, "Scanning assembly '{0}'...", moduleAssemblyFile.FullName ); DirectoryAssemblyLoadContext assemblyLoadContext = new DirectoryAssemblyLoadContext( fallbackDirectory: moduleAssemblyFile.Directory.FullName ); HelpItems help = new HelpItems(); MamlGenerator generator = new MamlGenerator(); Assembly moduleAssembly = assemblyLoadContext.LoadFromAssemblyPath(moduleAssemblyFile.FullName); foreach (Type cmdletType in Reflector.GetCmdletTypes(moduleAssembly)) { CmdletAttribute cmdletAttribute = cmdletType.GetTypeInfo().GetCustomAttribute <CmdletAttribute>(); Log.LogMessage(MessageImportance.Low, "Generating help for cmdlet '{0}-{1}' ('{2}').", cmdletAttribute.VerbName, cmdletAttribute.NounName, cmdletType.FullName ); help.Commands.Add( generator.Generate(cmdletType) ); } FileInfo helpFile = new FileInfo( HelpFile.GetMetadata("FullPath") ); if (helpFile.Exists) { helpFile.Delete(); } using (StreamWriter writer = helpFile.CreateText()) { help.WriteTo(writer); } Log.LogMessage(MessageImportance.Normal, "'{0}' -> '{1}'", moduleAssemblyFile.Name, helpFile.Name ); return(true); }
public void Generate_ThrowsArgumentNullException_Assembly() { Assert.Throws <ArgumentNullException>(() => { NormalMamlGenerator.Generate((Assembly)null); }); }