Getting warning PS0262 when compiling async method containing try/catch with a "when" condition

mattias.haggstrom's Avatar

mattias.haggstrom

27 Oct, 2017 06:29 AM

See attached sample. When compiling with VS2017 15.4.1, using PostSharp 5.0.35 I get a compiler warning "warning PS0262".

 private async Task MyMethod()
    {
        //
        // Compiling this will render a warning "postsharp\5.0.35\build\PostSharp.targets(314,5): warning PS0262: PostSharp encountered some recoverable errors while parsing the pdb file of PostSharpDebugSymbolTest.dll. The debugging experience may be affected."
        //
        // * Making the method sync, by changing signature to "private void MyMethod()" - will get rid of warning PS0262
        // * Removing the 'when' condition - will get rid of warning PS0262
        //
        try
        {
            await Task.Run(() => { });
            Console.WriteLine();
        }
        catch (Exception exception) when (Environment.TickCount == 0)
        {
            Console.WriteLine(exception);
        }
    }

It seems like there are 2 things in the method "MyMethod" that seem to cause this warning.
* The method is async * The try/catch has a "when" condition. If I change the code and remove any of these 2 conditions, it compiles without warnings.

(The attached sample also contains an aspect, but it's not really relevant for the issue described. I just have it there to avoid "warning PS0131: The project 'PostSharpDebugSymbolTest.dll' does not contain any aspect or other transformation")

Can you please have a look at this?
Thanks in advance,
Mattias

  1. Support Staff 1 Posted by PostSharp Techn... on 30 Oct, 2017 04:20 PM

    PostSharp Technologies's Avatar

    Hello,

    thank you for reporting this bug. We have internally filed it as issue #15600. We will contact you as soon as the bug fix has been released.

    For more details on our support policies and prioritization of bug fixes, please visit https://www.postsharp.net/support/policies.

    Do you experience any difficulties or is it just the warning at the moment?

    Best regards,
    -tony

  2. 2 Posted by mattias.haggstr... on 31 Oct, 2017 09:15 AM

    mattias.haggstrom's Avatar

    Hello,

    Thanks for the update.

    This is just a build warning for us, not a critical problem.

    Thanks,
    Mattias

  3. Support Staff 3 Posted by PostSharp Techn... on 31 Oct, 2017 10:00 AM

    PostSharp Technologies's Avatar

    OK, thank you.

    We're closing the ticket for now as the bug has been internally filed as mentioned above.

    Feel free to reopen the ticket eventually if you encounter any related issues before the bug is fixed.

    Best regards,
    -tony

  4. PostSharp Technologies closed this discussion on 31 Oct, 2017 10:00 AM.

  5. PostSharp Technologies re-opened this discussion on 02 Nov, 2017 09:57 AM

  6. Support Staff 4 Posted by PostSharp Techn... on 02 Nov, 2017 09:57 AM

    PostSharp Technologies's Avatar

    Hi Mattias,

    After analysis, we cannot fix this issue without introducing breaking changes in the API. Given the low severity of this bug (you would lose the lexical scope for exception variable of the catch-when blocks in async methods), we will not fix this issue in the 5.0 branch but instead in 5.1. In the meantime, you can quite safely suppress the warning and should suffer only very limited debugging discomfort.

    Our references: 15600, 15605

    Thanks,
    -gael

  7. PostSharp Technologies closed this discussion on 02 Nov, 2017 09:57 AM.

  8. PostSharp Technologies re-opened this discussion on 12 Jan, 2018 11:39 AM

  9. Support Staff 5 Posted by PostSharp Techn... on 12 Jan, 2018 11:39 AM

    PostSharp Technologies's Avatar

    Hello,

    we have released PostSharp 5.1.2 preview, which contains a fix of this bug. We would be grateful if you could confirm that the fix works for you.

    Thanks!

    Best regards,
    Daniel

  10. 6 Posted by mattias.haggstr... on 18 Jan, 2018 08:47 AM

    mattias.haggstrom's Avatar

    Sorry about the delay, I was on vacation. I have tested the preview now and I can confirm it works fine for us.

    Thanks for fixing!

  11. Support Staff 7 Posted by PostSharp Techn... on 19 Jan, 2018 09:48 AM

    PostSharp Technologies's Avatar

    Hello,

    We are glad that the fix helped.

    We are going to close this request. Please feel free to reopen the discussion if you need more help.

    Best regards,
    -jakub

  12. PostSharp Technologies closed this discussion on 19 Jan, 2018 09:48 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac