[6.0.27] Unhandled exception when defining an using-alias-statement

thijs.te.paske's Avatar

thijs.te.paske

08 Oct, 2018 01:06 PM

I ran into an issue using PostSharp and after spending several hours of troubleshooting I found out it was because of an using-alias statement.

When I try to build the .NET Standard 2.0 library, I get the following build output:

1>------ Build started: Project: PostSharpIssue, Configuration: Debug Any CPU ------
1>C:\Projects\PostSharpIssue\PostSharpIssue\PostSharpIssue.csproj : error PS0099: Unhandled exception (PostSharp.Compiler.Hosting.CommandLine.dll 6.0.27 release | .NET Core 2.1.4): System.NullReferenceException: Object reference not set to an instance of an object.
1>C:\Projects\PostSharpIssue\PostSharpIssue\PostSharpIssue.csproj : error PS0099: at PostSharp.Sdk.Binary.ModuleWriter.WriteTypeRef(TypeRefDeclaration _0, MetadataToken _1) in ^tezRMreC:line 1221
1>C:\Projects\PostSharpIssue\PostSharpIssue\PostSharpIssue.csproj : error PS0099: at PostSharp.Sdk.Binary.ModuleWriter.GetMappedType(IType _0) in ^tezRMreC:line 1197
1>C:\Projects\PostSharpIssue\PostSharpIssue\PostSharpIssue.csproj : error PS0099: at PostSharp.Sdk.Binary.ModuleWriter.WriteTypeDeclarationSignature(IType _0, BufferWriter _1, Boolean _2) in ^tezRMreC:line 1160
1>C:\Projects\PostSharpIssue\PostSharpIssue\PostSharpIssue.csproj : error PS0099: at ^OKKFOvYOQFk6.^Bvw5Ggn2() in ^0xHtxufIiR8T:line 874
1>C:\Projects\PostSharpIssue\PostSharpIssue\PostSharpIssue.csproj : error PS0099: at ^OKKFOvYOQFk6.^0fSnYazO(Stream _0) in ^0xHtxufIiR8T:line 698
1>C:\Projects\PostSharpIssue\PostSharpIssue\PostSharpIssue.csproj : error PS0099: at ^OKKFOvYOQFk6.WriteToFile() in ^0xHtxufIiR8T:line 667
1>C:\Projects\PostSharpIssue\PostSharpIssue\PostSharpIssue.csproj : error PS0099: at ^XLVeHKzJ.^SkiT() in ^62cDaY2Q:line 145
1>C:\Projects\PostSharpIssue\PostSharpIssue\PostSharpIssue.csproj : error PS0099: at ^XLVeHKzJ.^8KD6D2SV(String _0) in ^62cDaY2Q:line 163
1>C:\Projects\PostSharpIssue\PostSharpIssue\PostSharpIssue.csproj : error PS0099: at ^cyC/TYSlPGB/.^wvPm(^t9VuvqVboKU4 _0, ^RtksFin57NJ8 _1, ^8gP93Xsl\+Imn _2) in ^VLQPDfv+wmUE:line 24
1>C:\Projects\PostSharpIssue\PostSharpIssue\PostSharpIssue.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Tasks.CompileTask.Execute() in ^Fy2zcVesSTyC:line 341
1>C:\Projects\PostSharpIssue\PostSharpIssue\PostSharpIssue.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase) in ^hW2eIAWj:line 2332
1>C:\Projects\PostSharpIssue\PostSharpIssue\PostSharpIssue.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Project.Execute() in ^hW2eIAWj:line 2399
1>C:\Projects\PostSharpIssue\PostSharpIssue\PostSharpIssue.csproj : error PS0099: at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation) in D:\src\PostSharp-5\Core\PostSharp.Hosting\PostSharpObject.cs:line 283.
1>Done building project "PostSharpIssue.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

This exception can easily reproduced with the following steps:
1) Create a new .NET Standard 2.0 project
2) Install the PostSharp by adding PostSharp.Patterns.Common-package (version 6.0.27)
3) Replace (or add) the Class1.cs using the follow code-snippet:

using SomeUnusedAlias = System.String;


namespace PostsharpIssue { public class Class1 { public Class1([PostSharp.Patterns.Contracts.NotNull] string message) { } } }

The unhandled exception no longer occurs when I remove or comment the using-alias at line 1.

Attachment contains the info about visual studio and installed products.

  1. Support Staff 1 Posted by PostSharp Techn... on 09 Oct, 2018 09:57 AM

    PostSharp Technologies's Avatar

    Hello,

    this is a bug in our portable PDB writer. We will be working on a fix.

    As a temporary workaround you might switch to full Windows PDB, which does not have this behavior.

    (internal issue #20757)

    Thanks a lot for reporting the issue.

    Best regards,
    Daniel

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • Visual_Studio_Info.txt 5.74 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

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