Problem with C# nullable reference types
Problem reported by Chris - March 4 at 10:31 AM
Resolved
Hi ;)

GhostDoc can't handle Properties that need to be initialized with null due to the new nullable reference types.

Example:
 public class MyClass
    {

        /// <summary>
        /// Gets or sets the test.
        /// </summary>
        /// <value>
        /// The test.
        /// </value>
        public Object Test { get; set; }

        /// <summary>
        /// Gets or sets the test nullable.
        /// </summary>
        /// <value>
        /// The test nullable.
        /// </value>
        public Object TestNullable { get; set; } //= null!;

        /// <summary>
        /// Gets or sets the test nullable2.
        /// </summary>
        /// <value>
        /// The test nullable2.
        /// </value>
        public Object TestNullable2 { get; set; } = null!;

        public Object TestNullable3 { get; set; } = null!;

        public Object? TestNullable4 { get; set; } = null!;


    }
The "document this" function doesn't work after the first null "= null!;" initialization.
This null initialization is, unfortunately, necessary to prevent warnings when working with entity framework core.
For more info see the Microsoft Docs: > ef core with nullable reference types

Here is the log entry:
Log Message (04.03.2020 19:23:46) : DocumentThisCommandImplementation->Run... Log Message (04.03.2020 19:23:47) : GetAssemblyVersion: c:\users\christoph\appdata\local\microsoft\visualstudio\16.0_f657e153\extensions\vjyifdja.jyr\SubMain.GhostDoc.Package.dll Date and Time: 04.03.2020 19:23:47 IP Address: {0} OS Platform: Win32NT Processor: AMD64 OS version: 10.0.18363.0 Current user role:  User; Allocated Memory: 403 Mb Available Physical Memory: 4096 Mb Available Virtual Memory: 1279 Mb Total Physical Memory: 4096 Mb Total Virtual Memory: 4096 Mb Percentage of physical memory In use: 56 % NET Framework version: 4.0.30319.42000 Visual Studio version: 16.0 Visual Studio file: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe Visual Studio file version: 16.4.29806.167 Application Domain: DefaultDomain Product Version: 19.3.19260.0 Assembly Codebase: file:///c:/users/christoph/appdata/local/microsoft/visualstudio/16.0_f657e153/extensions/vjyifdja.jyr/SubMain.GhostDoc.Core.DLL Assembly Version: 2.2.0.0 Assembly Build Date: 18.12.2019 01:08:14 Assembly Full Name: SubMain.GhostDoc.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=94c677ee32cc1929 Exception Source: Parser exception Exception Message: error: identifier ';' expected, FileName: C:\Users\Christoph\Workspace\Repos\Flaterio\Flaterio.Data\Models\MyClass.cs Line: 32, Col: 58, Line text: "        public Object? TestNullable2 { get; set; } = null!;" Stack Trace :   at A.c2a633a86bc6520b19077f08c4d83eef0.Step(IToken t)   at A.c4b9bcf6ecf3441c482e2d00fec799f7f.c118fd19a2ada2835d2ac9c4c335599a1()   at A.c4b9bcf6ecf3441c482e2d00fec799f7f.c581074e4f15614505aaf43ef7c03ca58()   at A.c85d63cdad2a75941f7e65d2c2d359aad.c66772c4aca7dd32de5f62e3af4d8c3a8(ICompilationUnit , IClassInterface , INamespaceDeclaration )   at A.c85d63cdad2a75941f7e65d2c2d359aad.cbceecda92945e0fdceb8fc69cbec7b63()   at A.cb68d1b45010ff9a861d749e0871601be.cfb8d75f7155fc3a47e8a8718d15bb676(IRegion , INamespaceDeclaration , IType , ICompilationUnit , AttributeSectionCollection , MemberModifiers , IRegion )   at A.c2a633a86bc6520b19077f08c4d83eef0.NamespaceMember(INamespaceDeclaration currentNamespaceDeclaration)   at A.c2a633a86bc6520b19077f08c4d83eef0.NamespaceMember(INamespaceDeclaration currentNamespaceDeclaration) Log Message (04.03.2020 19:23:47) : ExecuteWithoutCodeDOM->_currentObjectUnderCursor == null at (34,31): "C:\Users\Christoph\Workspace\Repos\Flaterio\Flaterio.Data\Models\MyClass.cs" Log Message (04.03.2020 19:23:47) : ExecuteWithoutCodeDOM->_currentObjectUnderCursor == null at (34,31): "C:\Users\Christoph\Workspace\Repos\Flaterio\Flaterio.Data\Models\MyClass.cs" Log Message (04.03.2020 19:23:47) : No code element found at the current cursor position. Log Message (04.03.2020 19:23:47) : DocumentThisCommandImplementation->DocumentMembers... Log Message (04.03.2020 19:23:47) : GetAssemblyVersion: c:\users\christoph\appdata\local\microsoft\visualstudio\16.0_f657e153\extensions\vjyifdja.jyr\SubMain.GhostDoc.Package.dll Date and Time: 04.03.2020 19:23:47 IP Address: {0} OS Platform: Win32NT Processor: AMD64 OS version: 10.0.18363.0 Current user role:  User; Allocated Memory: 411 Mb Available Physical Memory: 4096 Mb Available Virtual Memory: 1279 Mb Total Physical Memory: 4096 Mb Total Virtual Memory: 4096 Mb Percentage of physical memory In use: 56 % NET Framework version: 4.0.30319.42000 Visual Studio version: 16.0 Visual Studio file: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe Visual Studio file version: 16.4.29806.167 Application Domain: DefaultDomain Product Version: 19.3.19260.0 Assembly Codebase: file:///c:/users/christoph/appdata/local/microsoft/visualstudio/16.0_f657e153/extensions/vjyifdja.jyr/SubMain.GhostDoc.Core.DLL Assembly Version: 2.2.0.0 Assembly Build Date: 18.12.2019 01:08:14 Assembly Full Name: SubMain.GhostDoc.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=94c677ee32cc1929 Exception Source: mscorlib Exception Type: System.ArgumentNullException Exception Message: DocumentMember: Collection cannot be null. Parameter name: c Exception Target Site: .ctor ---- Stack Trace ---- System.Collections.ArrayList..ctor(c As ICollection) SubMain.GhostDoc.Core.DLL: N 12830288 SubMain.GhostDoc.PropertyRuleArgs..ctor(configuration As RuleConfiguration, declaringTypeKind As String, declaringTypeName As String, declaringTypeTypeParameters As String[], memberModifiersValue As Int32, propertyTypeName As String, isPropertyTypeNullable As Boolean, propertyName As String, parameters As ParameterRuleArgs[], propertyAccessors As Accessors, existingDocumentationXml As String, inheritedDocumentationXml As String, codeLanguage As CodeLanguage, exceptions As Dictionary`2) SubMain.GhostDoc.Core.DLL: N 00231 A.c089a5a645a82bfc11363b8a6ac8d3a45.c9495450a44f85fef6ae7cb241984a67a( As RuleConfiguration,  As String,  As String,  As String[],  As Int32,  As String,  As Boolean,  As String,  As ParameterRuleArgs[],  As Accessors,  As String,  As String,  As CodeLanguage,  As Dictionary`2) SubMain.GhostDoc.Core.DLL: N 00060 A.c476f267f986334d5e33e073bcdbd1f86.cd822087bce47457322ab2922883a634b() SubMain.GhostDoc.Core.DLL: N 00311 A.c476f267f986334d5e33e073bcdbd1f86.c0d776bf94ff22ffe18c6ef8ce5689681( As Boolean) SubMain.GhostDoc.Core.DLL: N 00019 A.c34619165aba414d27648090d62429ef1.cea20907df77db43e6a93c9c36538560e( As c2ea400aa07f04bd1cebc5abf5f4aeff2,  As TextSelection,  As Object,  As CodeLanguage,  As Boolean) SubMain.GhostDoc.Core.DLL: N 00220 Log Message (04.03.2020 19:23:47) : DocumentThisCommandImplementation->Run finished. 

Thanks for your help.

1 Reply

Reply to Thread
0
Misha Zhutov Replied
Employee Post
Hi Chris, 

Thank you for reporting that. We have already fixed it and the fix will be available in the vNext soon.

Reply to Thread