Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Microsoft.AspNetCore.SystemWebAdapters/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,22 @@ internal static class Constants
internal const string DisposeIsRegistered = "Object is registered for dispose with HttpContext";

internal const string CA1859 = "False positive fixed by https://github.com/dotnet/roslyn-analyzers/pull/6421 but not integrated in yet";

internal static class TransferRequest
{
public const string Message = "TransferRequest is not supported on ASP.NET Core";
public const string DiagnosticId = "SYSWEB0001";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a different prefix we should use?

}

internal static class Execute
{
public const string Message = "Execute is not supported on ASP.NET Core";
public const string DiagnosticId = "SYSWEB0002";
}

internal static class Transfer
{
public const string Message = "Transfer is not supported on ASP.NET Core";
public const string DiagnosticId = "SYSWEB0003";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
#pragma warning disable CA1063 // Implement IDisposable Correctly
#pragma warning disable CA1816 // Dispose methods should call SuppressFinalize
#pragma warning disable CS0436 // Type conflicts with imported type

38 changes: 38 additions & 0 deletions src/Microsoft.AspNetCore.SystemWebAdapters/Generated/Obsolete.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#if NETSTANDARD
namespace System;

/// <summary>
/// An internal implementation to enable <see cref="DiagnosticId"/> on .NET Standard.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum |
AttributeTargets.Interface | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Delegate,
Inherited = false)]
internal sealed class ObsoleteAttribute : Attribute
{
public ObsoleteAttribute()
{
}

public ObsoleteAttribute(string? message)
{
Message = message;
}

public ObsoleteAttribute(string? message, bool error)
{
Message = message;
IsError = error;
}

public string? Message { get; }

public bool IsError { get; }

public string? DiagnosticId { get; set; }

public string? UrlFormat { get; set; }
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
#pragma warning disable CA1063 // Implement IDisposable Correctly
#pragma warning disable CA1816 // Dispose methods should call SuppressFinalize
#pragma warning disable CS0436 // Type conflicts with imported type

namespace System.Web
{
Expand Down Expand Up @@ -578,8 +579,28 @@ public partial class HttpServerUtility
internal HttpServerUtility() { }
public string MachineName { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
public void ClearError() { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
[System.ObsoleteAttribute("Execute is not supported on ASP.NET Core", DiagnosticId="SYSWEB0002")]
public void Execute(string path) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
[System.ObsoleteAttribute("Execute is not supported on ASP.NET Core", DiagnosticId="SYSWEB0002")]
public void Execute(string path, bool preserveForm) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
[System.ObsoleteAttribute("Execute is not supported on ASP.NET Core", DiagnosticId="SYSWEB0002")]
public void Execute(string path, System.IO.TextWriter writer) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
[System.ObsoleteAttribute("Execute is not supported on ASP.NET Core", DiagnosticId="SYSWEB0002")]
public void Execute(string path, System.IO.TextWriter writer, bool preserveForm) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
public System.Exception GetLastError() { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
public string MapPath(string path) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
[System.ObsoleteAttribute("Transfer is not supported on ASP.NET Core", DiagnosticId="SYSWEB0003")]
public void Transfer(string path) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
[System.ObsoleteAttribute("Transfer is not supported on ASP.NET Core", DiagnosticId="SYSWEB0003")]
public void Transfer(string path, bool preserveForm) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
[System.ObsoleteAttribute("TransferRequest is not supported on ASP.NET Core", DiagnosticId="SYSWEB0001")]
public void TransferRequest(string path) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
[System.ObsoleteAttribute("TransferRequest is not supported on ASP.NET Core", DiagnosticId="SYSWEB0001")]
public void TransferRequest(string path, bool preserveForm) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
[System.ObsoleteAttribute("TransferRequest is not supported on ASP.NET Core", DiagnosticId="SYSWEB0001")]
public void TransferRequest(string path, bool preserveForm, string method, System.Collections.Specialized.NameValueCollection headers) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
[System.ObsoleteAttribute("TransferRequest is not supported on ASP.NET Core", DiagnosticId="SYSWEB0001")]
public void TransferRequest(string path, bool preserveForm, string method, System.Collections.Specialized.NameValueCollection headers, bool preserveUser) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
public static byte[] UrlTokenDecode(string input) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
public static string UrlTokenEncode(byte[] input) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
#pragma warning disable CA1063 // Implement IDisposable Correctly
#pragma warning disable CA1816 // Dispose methods should call SuppressFinalize
#pragma warning disable CS0436 // Type conflicts with imported type

[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Web.HttpApplication))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Web.HttpApplicationState))]
Expand Down
32 changes: 32 additions & 0 deletions src/Microsoft.AspNetCore.SystemWebAdapters/HttpServerUtility.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Specialized;
using System.IO;
using System.Web.Hosting;
using Microsoft.AspNetCore.SystemWebAdapters;
using Microsoft.AspNetCore.WebUtilities;
Expand Down Expand Up @@ -83,4 +85,34 @@ public static string UrlTokenEncode(byte[] input)

return $"{encoded}{padding}";
}

[Obsolete(Constants.Execute.Message, DiagnosticId = Constants.Execute.DiagnosticId)]
public void Execute(string path) => throw new PlatformNotSupportedException();

[Obsolete(Constants.Execute.Message, DiagnosticId = Constants.Execute.DiagnosticId)]
public void Execute(string path, TextWriter writer) => throw new PlatformNotSupportedException();

[Obsolete(Constants.Execute.Message, DiagnosticId = Constants.Execute.DiagnosticId)]
public void Execute(string path, bool preserveForm) => throw new PlatformNotSupportedException();

[Obsolete(Constants.Execute.Message, DiagnosticId = Constants.Execute.DiagnosticId)]
public void Execute(string path, TextWriter writer, bool preserveForm) => throw new PlatformNotSupportedException();

[Obsolete(Constants.Transfer.Message, DiagnosticId = Constants.Transfer.DiagnosticId)]
public void Transfer(string path) => throw new PlatformNotSupportedException();

[Obsolete(Constants.Transfer.Message, DiagnosticId = Constants.Transfer.DiagnosticId)]
public void Transfer(string path, bool preserveForm) => throw new PlatformNotSupportedException();

[Obsolete(Constants.TransferRequest.Message, DiagnosticId = Constants.TransferRequest.DiagnosticId)]
public void TransferRequest(string path) => throw new PlatformNotSupportedException();

[Obsolete(Constants.TransferRequest.Message, DiagnosticId = Constants.TransferRequest.DiagnosticId)]
public void TransferRequest(string path, bool preserveForm) => throw new PlatformNotSupportedException();

[Obsolete(Constants.TransferRequest.Message, DiagnosticId = Constants.TransferRequest.DiagnosticId)]
public void TransferRequest(string path, bool preserveForm, string method, NameValueCollection headers) => throw new PlatformNotSupportedException();

[Obsolete(Constants.TransferRequest.Message, DiagnosticId = Constants.TransferRequest.DiagnosticId)]
public void TransferRequest(string path, bool preserveForm, string method, NameValueCollection headers, bool preserveUser) => throw new PlatformNotSupportedException();
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<Compile Remove="**/*" />
<Compile Include="Properties/PropertyInfo.cs" />
<Compile Include="Generated/Ref.*.cs" />
<Compile Include="Generated\Obsolete.cs" />
<Compile Include="Adapters/SessionState/ISessionState.cs" />
<Compile Include="IHtmlString.cs" />
<Compile Include="HtmlString.cs" />
Expand Down