dnSpyEx / dnSpy

Unofficial revival of the well known .NET debugger and assembly editor, dnSpy
GNU General Public License v3.0
6.83k stars 452 forks source link

Request for NullableContext and Nullable Support in dnSpyEx #230

Closed kasuganosora closed 1 year ago

kasuganosora commented 1 year ago

Problem Description

I am reaching out to bring to your attention an issue I have encountered while using dnSpy to edit code. Specifically, when attempting to recompile code that contains the NullableContext and Nullable attributes

code:

using System;
using System.Collections.Generic;
using System.Net.Http.Headers;
using System.Runtime.CompilerServices;

namespace System.Net.Http
{
    /// <summary>Represents a HTTP request message.</summary>
    // Token: 0x0200006C RID: 108
    [NullableContext(1)]
    [Nullable(0)]
    public partial class HttpRequestMessage : IDisposable
    {
        /// <summary>Initializes a new instance of the <see cref="T:System.Net.Http.HttpRequestMessage" /> class with an HTTP method and a request <see cref="T:System.Uri" />.</summary>
        /// <param name="method">The HTTP method.</param>
        /// <param name="requestUri">A string that represents the request  <see cref="T:System.Uri" />.</param>
        // Token: 0x0600034B RID: 843
        public HttpRequestMessage(HttpMethod method, [Nullable(2)] string requestUri)
            : this(method, string.IsNullOrEmpty(requestUri) ? null : new Uri(requestUri, UriKind.RelativeOrAbsolute))
        {
        }
    }
}

errors:

CS0246 The type or namespace name 'NullableContextAttribute' could not be found (are you missing a using directive or an assembly reference?) CS0246 The type or namespace name 'NullableContext' could not be found (are you missing a using directive or an assembly reference?) CS0616 'Nuliable' is not an attribute class CS0616 'Nullable' is not an attribute class CS0234 The type or namespace name 'NullableAttribute' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) 
3Z4t-main.cs main.cs main.cs main.cs main.g. 
45- 10 10 11 18 16 
CS0234 The type or namespace name 'Nullable' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) 
main.g. 16 
CS0234 The type or namespace CS0234 The type or namespace CS0234 The type or namespace CS0234 The type or namespace CS0234 The type or namespace CS0234 The type or namespace CS0234 The type or namespace CS0234 The type or namespace CS0234 The type or namespace CS0234 The type or namespace CS0234 The type or namespace CS0234 The type or namespace CS0234 The type or namespace CS0234 The type or namespace CS0234 The type or namespace 
name 'NullableAttribute' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) name 'Nullable' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) name 'NullableContextAttribute' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) name 'NullableContext' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) name 'NullableContextAttribute' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) name 'NullableContext' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) name 'NullableAttribute' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) name 'Nullable' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) name 'NullableContextAttribute' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) name 'NullableContext' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) name 'NullableContextAttribute' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) name 'NullableContext' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) name 'NullableAttribute' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) name 'Nullable' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) name 'NullableAttribute' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) 

Proposal

I wish to support these 2 features

Alternatives

No response

Additional Context

No response

ElektroKill commented 1 year ago

Support for nullable reference types will come when the decompiler engine is updated to ILSpy 8.x, an ongoing effort.

kasuganosora commented 1 year ago

Good! think you!

Ashesh3 commented 3 months ago

Seems like this issue is still relevant - how is the ILSpy 8.x coming along? :)

riQQ commented 3 months ago

See #5