XNA Creators Club Online
Page 1 of 1 (3 items)
Sort Posts: Previous Next

Using the ContentBuildLogger.LogWarning() method

Last post 11/3/2009 3:42 PM by mghoffmann. 2 replies.
  • 10/30/2009 4:48 PM

    Using the ContentBuildLogger.LogWarning() method

    I need a way to log a warning (that shows up in the errors/warnings window of Visual Studio) that includes the line and column of the error in their appropriate cells in said window. I've seen this done by the built-in content processors/importers, and so I'm guessing the way to do it is with the messageArgs parameter of the ContentBuildLogger.LogWarning() method, accessed by the context parameter of my custom processor. My problem is (betcha guessed it) that I have no idea what this parameter does. The method summary contains only this cryptic message regarding messageArgs:
    messageArgs:
    [ParamsArrayAttribute] Arguments for the reported message.
    Does this mean anything to anybody? I'm a bit lost when it comes to interpreting this summary of the messageArgs parameter. Can anybody tell me exactly how this parameter is used, or at least whether it does what I think it does? If not, can anyone show me how to do what I need?
    "It's pure sawesome!"
    http://hr.michaelgh.com/
  • 10/30/2009 5:48 PM In reply to

    Re: Using the ContentBuildLogger.LogWarning() method

    Answer
    Reply Quote
    The ContentIdentity parameter to LogWarning provides all the info about how to locate the error in the original content.  The FragmentIdentifier field can contain whatever data makes sense for your object type, but MSBuild/VisualStudio will process this specially if it is in the form "lineNumber" or "line,column".
    XNA Framework Developer - blog - homepage
  • 11/3/2009 3:42 PM In reply to

    Re: Using the ContentBuildLogger.LogWarning() method

    Thanks, Shawn- that worked perfectly. 
    For anyone else trying to do the same thing, remember that the line and column numbers are not zero-based, meaning the first line in the file is line 1, not line 0, and the first column in a line is column 1, not 0.  This can be a bit confusing when using the System.IO.File class's methods to get the index of the part of the file that's wrong, but it's easy to fix.
    "It's pure sawesome!"
    http://hr.michaelgh.com/
Page 1 of 1 (3 items) Previous Next