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

Using the ContentBuildLogger.LogWarning() method

Last post 03/11/2009 3:42 PM by mghoffmann. 2 replies.
  • 30/10/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?
    --
    "Back in my day, we didn't have Wiis. The best we had were chunky, irregularly shaped systems that were named after their processors or whether they had color or not. You could only play them if you had three hands, the joysticks only lasted 2 weeks before falling out, and they used cartridges (those are like DS Cards, only way bigger, and they run on dust and spit), but most kids played ‘em anyway. The best games were about a little boy in a green skirt that killed an old puke-brown-skinned red-haired organ-playing dinosaur-man, kept a boomerang, a slingshot, a bow, and bombs in his pocketless tights, and befriended a cross-dressing princess that stalked him. There was also the one game about a short Italian plumber that ate wild mushrooms, jumped off walls, slaughtered cute little turtles just because they were in his way, and killed the last of the dinosaurs, a dragon named Bowser. Those were the days..."
    --Michael Hoffmann
  • 30/10/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
  • 03/11/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.
    --
    "Back in my day, we didn't have Wiis. The best we had were chunky, irregularly shaped systems that were named after their processors or whether they had color or not. You could only play them if you had three hands, the joysticks only lasted 2 weeks before falling out, and they used cartridges (those are like DS Cards, only way bigger, and they run on dust and spit), but most kids played ‘em anyway. The best games were about a little boy in a green skirt that killed an old puke-brown-skinned red-haired organ-playing dinosaur-man, kept a boomerang, a slingshot, a bow, and bombs in his pocketless tights, and befriended a cross-dressing princess that stalked him. There was also the one game about a short Italian plumber that ate wild mushrooms, jumped off walls, slaughtered cute little turtles just because they were in his way, and killed the last of the dinosaurs, a dragon named Bowser. Those were the days..."
    --Michael Hoffmann
Page 1 of 1 (3 items) Previous Next