本文整理汇总了C#中IVsOutputWindowPane.OutputStringThreadSafe方法的典型用法代码示例。如果您正苦于以下问题:C# IVsOutputWindowPane.OutputStringThreadSafe方法的具体用法?C# IVsOutputWindowPane.OutputStringThreadSafe怎么用?C# IVsOutputWindowPane.OutputStringThreadSafe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVsOutputWindowPane
的用法示例。
在下文中一共展示了IVsOutputWindowPane.OutputStringThreadSafe方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildAsync
internal override void BuildAsync(uint vsopts, string config, IVsOutputWindowPane output, string target, Action<MSBuildResult, string> uiThreadCallback) {
var xSolutionBuildManager = (IVsSolutionBuildManager)this.GetService(typeof(IVsSolutionBuildManager));
var xSolution = (IVsSolution)this.GetService(typeof(IVsSolution));
if (xSolutionBuildManager != null && xSolution != null) {
IVsHierarchy xStartupProj;
xSolutionBuildManager.get_StartupProject(out xStartupProj);
if (xStartupProj != null) {
var xProj = xStartupProj as IVsProject3;
Guid xGuid;
xSolution.GetGuidOfProject(xStartupProj, out xGuid);
if (xGuid != Guid.Empty) {
if (xGuid != this.ProjectIDGuid) {
uiThreadCallback(MSBuildResult.Successful, "Skipped");
output.OutputStringThreadSafe("Project skipped, as it's not necessary for running\r\n\r\n");
return;
}
}
}
}
base.BuildAsync(vsopts, config, output, target, uiThreadCallback);
}
示例2: Build
public void Build(uint options, IVsOutputWindowPane output, string target)
{
// We want to refresh the references if we are building with the Build or Rebuild target.
bool shouldRepaintReferences = (target == null || target == MsBuildTarget.Build || target == MsBuildTarget.Rebuild);
if (!NotifyBuildBegin()) return;
try
{
config.ProjectMgr.BuildAsync(options, this.config.ConfigCanonicalName, output, target, (result, projectInstance) =>
{
this.BuildCoda(new BuildResult(result, projectInstance), output, shouldRepaintReferences);
});
}
catch (Exception e)
{
Trace.WriteLine("Exception : " + e.Message);
ErrorHandler.ThrowOnFailure(output.OutputStringThreadSafe("Unhandled Exception:" + e.Message + "\n"));
this.BuildCoda(new BuildResult(MSBuildResult.Failed, null), output, shouldRepaintReferences);
throw;
}
}
示例3: Build
private void Build(uint options, IVsOutputWindowPane output, string target)
{
if (!this.config.ProjectMgr.HasPassedSecurityChecks)
{
// From a security perspective, if there was something truly malicious about the project,
// the user is about to toast himself by requesting a build. Any further attempts at
// preventing damage by avoiding MSBuild targets/tasks are futile. So, from this point
// forward, we might as well pretend that this project has passed all security checks,
// and we're free to run any targets we like.
this.config.ProjectMgr.HasPassedSecurityChecks = true;
}
// We want to refresh the references if we are building with the Build or Rebuild target or if the project was opened for browsing only.
bool shouldRepaintReferences = (target == null || target == MsBuildTarget.Build || target == MsBuildTarget.Rebuild
|| !this.config.ProjectMgr.HasPassedSecurityChecks);
int shouldContinue = 1;
foreach (IVsBuildStatusCallback cb in callbacks)
{
try
{
ErrorHandler.ThrowOnFailure(cb.BuildBegin(ref shouldContinue));
if (shouldContinue == 0)
return;
}
catch (Exception e)
{
// If those who ask for status have bugs in their code it should not prevent the build/notification from happening
Debug.Fail(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.BuildEventError, CultureInfo.CurrentUICulture), e.Message));
}
}
MSBuildResult result = MSBuildResult.Failed;
try
{
result = config.ProjectMgr.Build(options, this.config.ConfigName, output, target);
}
catch (Exception e)
{
Trace.WriteLine("Exception : " + e.Message);
ErrorHandler.ThrowOnFailure(output.OutputStringThreadSafe("Unhandled Exception:" + e.Message + "\n"));
throw e;
}
finally
{
int success = ((result == MSBuildResult.Successful) ? 1 : 0);
foreach (IVsBuildStatusCallback cb in callbacks)
{
try
{
ErrorHandler.ThrowOnFailure(cb.BuildEnd(success));
}
catch (Exception e)
{
// If those who ask for status have bugs in their code it should not prevent the build/notification from happening
Debug.Fail(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.BuildEventError, CultureInfo.CurrentUICulture), e.Message));
}
}
ErrorHandler.ThrowOnFailure(output.FlushToTaskList());
// Now repaint references if that is needed.
// We hardly rely here on the fact the ResolveAssemblyReferences target has been run as part of the build.
// One scenario to think at is when an assembly reference is renamed on disk thus becomming unresolvable,
// but msbuild can actually resolve it.
// Another one if the project was opened only for browsing and now the user chooses to build or rebuild.
if (shouldRepaintReferences && (result == MSBuildResult.Successful))
{
this.RefreshReferences();
}
}
}
示例4: OutputWindowLogger
/// <summary>
/// Creates a logger instance
/// </summary>
/// <param name="shouldLog">Predicate that will be called when logging. Should return true if logging is to be performed, false otherwise.</param>
/// <param name="pane">The output pane where logging should be targeted</param>
public OutputWindowLogger(Func<bool> shouldLog, IVsOutputWindowPane pane)
{
this.predicate = shouldLog;
if (pane is IVsOutputWindowPaneNoPump)
{
var asNoPump = pane as IVsOutputWindowPaneNoPump;
this.print = (s) => asNoPump.OutputStringNoPump(s);
}
else
{
this.print = (s) => pane.OutputStringThreadSafe(s);
}
}
示例5: Build
private void Build(uint options, IVsOutputWindowPane output, string target) {
if (!this.NotifyBuildBegin()) {
return;
}
try {
config.ProjectMgr.BuildAsync(options, this.config.ConfigName, output, target, (result, buildTarget) => this.NotifyBuildEnd(result, buildTarget));
} catch (Exception e) {
if (e.IsCriticalException()) {
throw;
}
Trace.WriteLine("Exception : " + e.Message);
ErrorHandler.ThrowOnFailure(output.OutputStringThreadSafe("Unhandled Exception:" + e.Message + "\n"));
this.NotifyBuildEnd(MSBuildResult.Failed, target);
throw;
} finally {
ErrorHandler.ThrowOnFailure(output.FlushToTaskList());
}
}
示例6: StreamOutput
private static void StreamOutput(Process/*!*/ process, StreamReader/*!*/ from, IVsOutputWindowPane/*!*/ output, BackgroundWorker worker)
{
while (!process.HasExited) {
string line;
while ((line = from.ReadLine()) != null) {
output.OutputStringThreadSafe(line);
output.OutputStringThreadSafe("\n");
worker.ReportProgress(5);
}
}
}
示例7: VsGitFlowWrapper
public VsGitFlowWrapper(string repoPath,IVsOutputWindowPane outputWindow)
: base(repoPath)
{
CommandOutputDataReceived += (o, args) => outputWindow.OutputStringThreadSafe(args.Output);
CommandErrorDataReceived += (o, args) => outputWindow.OutputStringThreadSafe(args.Output);
}
示例8: ObsoleteBuild
public virtual bool ObsoleteBuild(uint vsopts, string config, IVsOutputWindowPane output, bool fCleanBuild)
{
if (fCleanBuild)
{
// we are done
return true;
}
lock (Project.BuildLock)
{
ProjectOptions options = this.GetProjectOptions(config);
CompilerResults results;
ArrayList files = new ArrayList();
/*UNDONE: need to get this to use MSBuild
foreach (XmlElement e in doc.SelectNodes("//Files/Include/File"))
{
//TODO: Support other "BuildActions" like "EmbeddedResource"...
if (e.GetAttribute("BuildAction") == "Compile")
{
string rel = e.GetAttribute("RelPath");
Url url = new Url(new Url(doc.BaseURI), rel);
files.Add(url.AbsoluteUrl);
}
}
*/
try
{
ICodeCompiler compiler = this.GetCompiler();
if (files.Count == 1)
{
string filename = (string)files[0];
results = compiler.CompileAssemblyFromFile(options, filename);
}
else
{
string[] fileNames = (string[])files.ToArray(typeof(string));
results = compiler.CompileAssemblyFromFileBatch(options, fileNames);
}
}
catch (Exception e)
{
results = new CompilerResults(options.TempFiles);
results.Errors.Add(new CompilerError(options.OutputAssembly, 1, 1, "", "Internal Compiler Error: " + e.ToString() + "\n"));
results.NativeCompilerReturnValue = 1;
}
taskProvider.Tasks.Clear();
int errorCount = 0;
int warningCount = 0;
foreach (CompilerError e in results.Errors)
{
if (e.IsWarning) warningCount++;
else
errorCount++;
NativeMethods.ThrowOnFailure(output.OutputTaskItemString(GetFormattedErrorMessage(e, false) + "\n", VSTASKPRIORITY.TP_HIGH, VSTASKCATEGORY.CAT_BUILDCOMPILE, "", -1, e.FileName, (uint)e.Line - 1, e.ErrorText));
}
NativeMethods.ThrowOnFailure(output.OutputStringThreadSafe("Build complete -- " + errorCount + " errors, " + warningCount + " warnings")); //TODO: globalize
NativeMethods.ThrowOnFailure(output.FlushToTaskList());
return results.NativeCompilerReturnValue == 0;
}
}
示例9: Build
//////////////////////////////////////////////////////////////////////////////////////////////////
// This is called from the compiler background thread.
// fCleanBuild is not part of the vsopts, but passed down as the callpath is differently
//
//////////////////////////////////////////////////////////////////////////////////////////////////
/// <include file='doc\Project.uex' path='docs/doc[@for="Project.Build"]/*' />
public virtual bool Build(uint vsopts, XmlElement config, IVsOutputWindowPane output, bool fCleanBuild){
if (fCleanBuild){
// we are done
return true;
}
lock (Project.BuildLock){
#if LookForMemoryLeaks
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
long usedMemoryBeforeBuild = System.GC.GetTotalMemory(true);
#endif
int errorCount = 0;
int warningCount = 0;
CompilerResults results = this.CompileProject(config);
#if WHIDBEY
if (this.taskManager != null && this.taskManagerBuild != null) {
taskManager.ClearTasksOnProject(this.Caption);
taskManagerBuild.ClearTasksOnProject(this.Caption);
bool runVerifierBuildOnly = this.GetBoolAttr(config, "RunProgramVerifier") && !this.GetBoolAttr(config, "RunProgramVerifierWhileEditing");
string verifierCode = ((int)System.Compiler.Error.GenericWarning).ToString("0000");
foreach (CompilerError e in results.Errors) {
if (e.IsWarning)
warningCount++;
else
errorCount++;
// output.OutputTaskItemString(GetFormattedErrorMessage(e, false) + "\n", VSTASKPRIORITY.TP_HIGH, VSTASKCATEGORY.CAT_BUILDCOMPILE, "", -1, e.FileName, (uint)e.Line - 1, e.ErrorText);
int endLine;
int endColumn;
if (e is System.Compiler.CompilerErrorEx) {
System.Compiler.CompilerErrorEx errorEx = (System.Compiler.CompilerErrorEx)e;
endLine = errorEx.EndLine;
endColumn = errorEx.EndColumn;
}
else {
endLine = e.Line;
endColumn = e.Column + 1;
}
bool isBuildOnly = runVerifierBuildOnly && e.ErrorNumber == verifierCode;
(isBuildOnly ? taskManagerBuild : taskManager).AddTask(e.ErrorText, null, e.ErrorNumber, "CS" + e.ErrorNumber,
TaskPriority.Normal, (e.IsWarning ? TaskCategory.Warning : TaskCategory.Error),
(isBuildOnly ? TaskMarker.Error : (e.IsWarning ? TaskMarker.Warning : TaskMarker.CodeSense)),
TaskOutputPane.Build, this.Caption, e.FileName,
e.Line, e.Column, endLine, endColumn, null);
}
taskManager.OutputString("Build complete -- " + errorCount + " errors, " + warningCount + " warnings\n", TaskOutputPane.Build);
taskManager.Refresh();
taskManagerBuild.Refresh();
}
else {
#endif
this.taskProvider.ClearErrors();
foreach (CompilerError e in results.Errors) {
if (e.IsWarning) warningCount++;
else
errorCount++;
output.OutputTaskItemString(GetFormattedErrorMessage(e, false) + "\n", VSTASKPRIORITY.TP_HIGH, VSTASKCATEGORY.CAT_BUILDCOMPILE, "", -1, e.FileName, (uint)e.Line - 1, e.ErrorText);
}
output.OutputStringThreadSafe("Build complete -- " + errorCount + " errors, " + warningCount + " warnings\n"); //TODO: globalize
output.FlushToTaskList();
#if WHIDBEY
}
#endif
bool success = results.NativeCompilerReturnValue == 0;
#if LookForMemoryLeaks
results = null;
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
long usedMemoryAfterBuild = System.GC.GetTotalMemory(true);
output.OutputStringThreadSafe("Build leaked "+(usedMemoryAfterBuild-usedMemoryBeforeBuild)+" bytes");
#endif
return success;
}
}
示例10: WriteLineToPane
private static void WriteLineToPane(IVsOutputWindowPane pane, string messageFormat, params object[] args)
{
int hr = pane.OutputStringThreadSafe(string.Format(CultureInfo.CurrentCulture, messageFormat, args: args) + Environment.NewLine);
Debug.Assert(ErrorHandler.Succeeded(hr), "Failed in OutputStringThreadSafe: " + hr.ToString());
}
示例11: Build
private void Build(uint options, IVsOutputWindowPane output, string target)
{
int shouldContinue = 1;
foreach (IVsBuildStatusCallback cb in callbacks)
{
try
{
ErrorHandler.ThrowOnFailure(cb.BuildBegin(ref shouldContinue));
if (shouldContinue == 0)
return;
}
catch (Exception e)
{
// If those who ask for status have bugs in their code it should not prevent the build/notification from happening
Debug.Fail(String.Format("Exception was thrown during BuildBegin event\n{0}", e.Message));
}
}
MSBuildResult result = MSBuildResult.Failed;
try
{
result = config.ProjectMgr.Build(options, this.config.ConfigName, output, target);
}
catch (Exception e)
{
Trace.WriteLine("Exception : " + e.Message);
ErrorHandler.ThrowOnFailure(output.OutputStringThreadSafe("Unhandled Exception:" + e.Message + "\n"));
throw e;
}
finally
{
int success = ((result == MSBuildResult.Sucessful) ? 1 : 0);
foreach (IVsBuildStatusCallback cb in callbacks)
{
try
{
ErrorHandler.ThrowOnFailure(cb.BuildEnd(success));
}
catch (Exception e)
{
// If those who ask for status have bugs in their code it should not prevent the build/notification from happening
Debug.Fail(String.Format("Exception was thrown during BuildEnd event\n{0}", e.Message));
}
}
ErrorHandler.ThrowOnFailure(output.FlushToTaskList());
}
}
示例12: Message
//--//
private void Message(IVsOutputWindowPane pane, String msg)
{
if(pane == null)
return;
if(msg==null)
msg = "[no message string provided to MessageCentre.Message()" + new StackTrace().ToString();
try
{
lock (pane)
{
pane.Activate();
pane.OutputStringThreadSafe(msg + "\r\n");
}
}
catch( InvalidComObjectException )
{
}
}