Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm] Mark System.Console APIs as unsupported on Browser #41184

Merged
4 commits merged into from
Sep 4, 2020

Conversation

mdh1418
Copy link
Member

@mdh1418 mdh1418 commented Aug 21, 2020

Contributes to #41087

browser M:System.Console.set_BufferWidth(System.Int32),System,Console,set_BufferWidth(Int32),1 
windows "M:System.Console.MoveBufferArea(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Char,System.ConsoleColor,System.ConsoleColor)",System,Console,"MoveBufferArea(Int32, Int32, Int32, Int32, Int32, Int32, Char, ConsoleColor, ConsoleColor)",1
windows M:System.Console.set_WindowTop(System.Int32),System,Console,set_WindowTop(Int32),1
browser M:System.Console.add_CancelKeyPress(System.ConsoleCancelEventHandler),System,Console,add_CancelKeyPress(ConsoleCancelEventHandler),1
browser M:System.Console.Beep,System,Console,Beep(),1
browser M:System.Console.get_ForegroundColor,System,Console,get_ForegroundColor(),1
browser M:System.Console.set_CursorVisible(System.Boolean),System,Console,set_CursorVisible(Boolean),1
browser M:System.Console.get_In,System,Console,get_In(),2
browser M:System.Console.set_CursorTop(System.Int32),System,Console,set_CursorTop(Int32),2
browser M:System.Console.get_CursorSize,System,Console,get_CursorSize(),1
browser M:System.Console.set_WindowWidth(System.Int32),System,Console,set_WindowWidth(Int32),1
browser M:System.Console.get_CursorLeft,System,Console,get_CursorLeft(),1
browser M:System.Console.ResetColor,System,Console,ResetColor(),1
browser M:System.Console.get_CursorVisible,System,Console,get_CursorVisible(),1
browser "M:System.Console.SetCursorPosition(System.Int32,System.Int32)",System,Console,"SetCursorPosition(Int32, Int32)",1
browser M:System.Console.OpenStandardInput,System,Console,OpenStandardInput(),1
browser M:System.Console.set_WindowHeight(System.Int32),System,Console,set_WindowHeight(Int32),1
windows "M:System.Console.SetBufferSize(System.Int32,System.Int32)",System,Console,"SetBufferSize(Int32, Int32)",1
browser M:System.Console.set_CursorLeft(System.Int32),System,Console,set_CursorLeft(Int32),2
browser M:System.Console.remove_CancelKeyPress(System.ConsoleCancelEventHandler),System,Console,remove_CancelKeyPress(ConsoleCancelEventHandler),1
browser M:System.Console.get_Title,System,Console,get_Title(),1
browser M:System.Console.set_InputEncoding(System.Text.Encoding),System,Console,set_InputEncoding(Encoding),1
windows "M:System.Console.Beep(System.Int32,System.Int32)",System,Console,"Beep(Int32, Int32)",1
browser M:System.Console.get_CursorTop,System,Console,get_CursorTop(),1
windows "M:System.Console.MoveBufferArea(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32)",System,Console,"MoveBufferArea(Int32, Int32, Int32, Int32, Int32, Int32)",1
browser M:System.Console.get_WindowWidth,System,Console,get_WindowWidth(),1
browser M:System.Console.get_LargestWindowHeight,System,Console,get_LargestWindowHeight(),1
browser M:System.Console.set_TreatControlCAsInput(System.Boolean),System,Console,set_TreatControlCAsInput(Boolean),1
windows "M:System.Console.SetWindowSize(System.Int32,System.Int32)",System,Console,"SetWindowSize(Int32, Int32)",1
windows M:System.Console.get_NumberLock,System,Console,get_NumberLock(),1
browser M:System.Console.ReadKey,System,Console,ReadKey(),1
browser M:System.Console.get_BufferHeight,System,Console,get_BufferHeight(),1
browser M:System.Console.get_BufferWidth,System,Console,get_BufferWidth(),1
browser M:System.Console.ReadKey(System.Boolean),System,Console,ReadKey(Boolean),1
browser M:System.Console.get_InputEncoding,System,Console,get_InputEncoding(),1
browser M:System.Console.ReadLine,System,Console,ReadLine(),3
browser M:System.Console.get_WindowHeight,System,Console,get_WindowHeight(),1
browser M:System.Console.set_BackgroundColor(System.ConsoleColor),System,Console,set_BackgroundColor(ConsoleColor),1
browser M:System.Console.set_ForegroundColor(System.ConsoleColor),System,Console,set_ForegroundColor(ConsoleColor),1
browser M:System.Console.set_CursorSize(System.Int32),System,Console,set_CursorSize(Int32),1
windows M:System.Console.get_CapsLock,System,Console,get_CapsLock(),1
windows "M:System.Console.SetWindowPosition(System.Int32,System.Int32)",System,Console,"SetWindowPosition(Int32, Int32)",1
browser M:System.Console.OpenStandardInput(System.Int32),System,Console,OpenStandardInput(Int32),2
browser M:System.Console.set_BufferHeight(System.Int32),System,Console,set_BufferHeight(Int32),1
browser M:System.Console.get_BackgroundColor,System,Console,get_BackgroundColor(),1
browser M:System.Console.Read,System,Console,Read(),3
browser M:System.Console.GetCursorPosition,System,Console,GetCursorPosition(),1
browser M:System.Console.Clear,System,Console,Clear(),1
browser M:System.Console.get_TreatControlCAsInput,System,Console,get_TreatControlCAsInput(),1
browser M:System.Console.set_Title(System.String),System,Console,set_Title(String),1
windows M:System.Console.set_WindowLeft(System.Int32),System,Console,set_WindowLeft(Int32),1
browser M:System.Console.get_LargestWindowWidth,System,Console,get_LargestWindowWidth(),1

@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@ghost
Copy link

ghost commented Aug 21, 2020

Tagging subscribers to this area: @safern, @ViktorHofer
See info in area-owners.md if you want to be subscribed.

@mdh1418 mdh1418 force-pushed the mdhwang/system_console_unsupporetd branch from b958789 to 091167b Compare September 3, 2020 00:48
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
public static bool NumberLock { get { throw null; } }
public static System.IO.TextWriter Out { get { throw null; } }
public static System.Text.Encoding OutputEncoding { get { throw null; } set { } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public static string Title { [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] get { throw null; } set { } }
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure is this would be considered an "inconsistent list." Should [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] instead be applied right before set?

Copy link
Member

Choose a reason for hiding this comment

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

I just posted a similar question on the src file before seeing this comment. #41184 (comment)

Comment on lines 399 to 405
[UnsupportedOSPlatform("browser")]
public static bool CursorVisible
{
[SupportedOSPlatform("windows")]
get { return ConsolePal.CursorVisible; }
set { ConsolePal.CursorVisible = value; }
}
Copy link
Member

Choose a reason for hiding this comment

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

This is an interesting scenario! @buyaa-n can you weigh in on how this will be interpreted with the property being marked as [Unsupported("browser")] but the get method having [SupportedOSPlatform("windows")]? Is this OK or should we instead mark the set method as [UnsupportedOSPlatform("browser")]?

Copy link
Member

Choose a reason for hiding this comment

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

Is the UnsupportedOSPlatform even necessary? I imagine that the behavior of the analyzer would be "if there is a SupportedOSPlatformAttribute" it will flag the API as unsupported on any other platforms?

Maybe we should just mark the whole property as SupportedOSPlatform("windows")? It seems weird to be able to set a property that you can't get on the same platform? Or does this property affects other APIs that are supported?

Copy link
Member

Choose a reason for hiding this comment

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

What was intended here was to mark the property getter as supported only on Windows, but the property setter as supported everywhere (except browser now). The getter and setter can have their own attributes. But I don't know what the analyzer will do when the getter/setter differ from the property itself like this.

It might be clearer to just mark the set method as [UnsupportedOSPlatform("browser")] even if this would actually work as-is.

Copy link
Member

Choose a reason for hiding this comment

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

I see. Maybe something to consider on the Analyzer? That if the property has an attribute, but the getter/setter has another, the getter/setter wins?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is an interesting scenario! @buyaa-n can you weigh in on how this will be interpreted with the property being marked as [Unsupported("browser")] but the get method having [SupportedOSPlatform("windows")]? Is this OK or should we instead mark the set method as [UnsupportedOSPlatform("browser")]?

Yes it would be considered as an inconsistent list, as you mentioned the [UnsupportedOSPlatform("browser")] attribute better to be in the setter.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Maybe something to consider on the Analyzer? That if the property has an attribute, but the getter/setter has another, the getter/setter wins?

It works that way in case they are for the same platform, but not for different platform

Copy link
Member

Choose a reason for hiding this comment

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

Cool. @mdh1418 per these comments, please update all properties where there was already [SupportedOSPlatform("windows")] on one of the accessors but not the other, and move the [UnsupportedOSPlatform("browser")] attribute down to the other accessor instead of on the property itself.

Copy link
Member

@jeffhandley jeffhandley left a comment

Choose a reason for hiding this comment

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

move UnsupportedOSPlatform attributes down to the accessor

Sorry, I probably wasn't clear enough in my previous comment. We should only move attributes down to the accessors when there are existing attributes on the other accessor.

For properties only with get, the attribute can be on the property itself. And for properties with both get and set that did not previously have [SupportedOSPlatform("windows")] you should also apply the new attribute to the entire property (assuming both accessors are unsupported on browser).

We only need to move the attribute to the accessors when support between the 2 accessors differs.

@mdh1418 mdh1418 force-pushed the mdhwang/system_console_unsupporetd branch from 31abd9c to 30783d8 Compare September 4, 2020 18:54
@mdh1418
Copy link
Member Author

mdh1418 commented Sep 4, 2020

For properties only with get, the attribute can be on the property itself. And for properties with both get and set that did not previously have [SupportedOSPlatform("windows")] you should also apply the new attribute to the entire property (assuming both accessors are unsupported on browser).

Ah, right, so the attribute will be applied to the highest level. I removed a commit that had previously moved the attributes down to the accessor level.

Copy link
Member

@jeffhandley jeffhandley left a comment

Choose a reason for hiding this comment

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

Thanks!! This is exciting to see.

@ghost
Copy link

ghost commented Sep 4, 2020

Hello @safern!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit a9f6fd6 into dotnet:master Sep 4, 2020
mdh1418 added a commit to mdh1418/runtime that referenced this pull request Sep 8, 2020
* [wasm] Mark System.Console APIs as unsupported on Browser

* System.Console remove unsupported attribute from Console.Clear()

* System.Console mark SetIn as unsupported on Browser

* System.Console move UnsupportedOSPlatform attributes down to the accessor

Co-authored-by: Mitchell Hwang <mitchell.hwang@microsoft.com>
@mdh1418 mdh1418 deleted the mdhwang/system_console_unsupporetd branch September 8, 2020 16:23
mdh1418 added a commit that referenced this pull request Sep 9, 2020
* [wasm] Mark System.ComponentModel APIs as unsupported on Browser (#41094)

* [wasm] System.ComponentModel enable platform attributes

* [wasm] Mark ExtendedProtectionPolicyTypeConverter.ConvertTo as unsupported

* [wasm] Mark System.ComponentModel.TypeDescriptor.CreateInstance as unsupported

* [wasm] Mark System.ComponentModel.TypeDescriptionProvider.CreateInstance as unsupported

* [wasm] Mark System.ComponentModel.LicenseManager.CreateWithContext as unsupported

* [wasm] Mark System.ComponentModel.MaskedTextProvider.Clone as unsupported

Co-authored-by: Mitchell Hwang <mitchell.hwang@microsoft.com>

* [wasm] Mark System.Console APIs as unsupported on Browser (#41184)

* [wasm] Mark System.Console APIs as unsupported on Browser

* System.Console remove unsupported attribute from Console.Clear()

* System.Console mark SetIn as unsupported on Browser

* System.Console move UnsupportedOSPlatform attributes down to the accessor

Co-authored-by: Mitchell Hwang <mitchell.hwang@microsoft.com>

* Mark System.Diagnostics.FileVersionInfo as unsupported on Browser (#41271)

Co-authored-by: Mitchell Hwang <mitchell.hwang@microsoft.com>

* Mark System.Diagnostics.Process unsupported at assembly level (#41694)

Co-authored-by: Mitchell Hwang <mitchell.hwang@microsoft.com>

* [wasm] Mark System.IO.Compression APIs as unsupported on Browser (#41683)

* [wasm] System.IO.Compression.Brotli enable platform attributes

* Mark System.IO.Compression.Brotli unsupported at assembly level

Co-authored-by: Mitchell Hwang <mitchell.hwang@microsoft.com>

* [wasm] Mark System.IO.FileSystem.Watcher APIs as unsupported on Browser (#41682)

* [wasm] System.IO.FileSystem.Watcher enable platform attributes

* Mark System.IO.FileSystem.Watcher unsupported at assembly level

Co-authored-by: Mitchell Hwang <mitchell.hwang@microsoft.com>

* [wasm] Mark System.IO.IsolatedStorage APIs as unsupported on Browser (#41700)

* [wasm] System.IO.IsolatedStorage enable platform attributes

* Mark System.IO.IsolatedStorage Unsupported at assembly level

Co-authored-by: Mitchell Hwang <mitchell.hwang@microsoft.com>

* Mark some System.Net.* APIs as unsupported on Browser WASM (#40924)

* [wasm] Mark System.Threading.ThreadPool unsupported on Browser (#41891)

* System.Threading.ThreadPool enable platform attributes

* Mark System.Threading.ThreadPool APIs unsupported on browser

* System.Threading.ThreadPool Add Unsupported attribute to other ThreadPool files

* Remove Unsupported attributes from BindHandle

* Add windows Supported Attribute to BindHandle

Co-authored-by: Mitchell Hwang <mitchell.hwang@microsoft.com>

* Mark System.Net.WebSockets.ClientWebSocketOptions APIs as unsupported on Browser (#41963)

* Mark System.Net.WebSockets.ClientWebSocketOptions APIs as unsupported on Browser

* Add the attributes to non-browser version of ClientWebSocketOptions class to avoid build error

* Add using

* Include platform attributes

* [wasm] Mark System.Net.NameResolution Unsupported at assembly level (#41985)

Co-authored-by: Mitchell Hwang <mitchell.hwang@microsoft.com>

Co-authored-by: Mitchell Hwang <mitchell.hwang@microsoft.com>
Co-authored-by: Maxim Lipnin <v-maxlip@microsoft.com>
mdh1418 added a commit to mdh1418/runtime that referenced this pull request Sep 11, 2020
* [wasm] Mark System.Console APIs as unsupported on Browser

* System.Console remove unsupported attribute from Console.Clear()

* System.Console mark SetIn as unsupported on Browser

* System.Console move UnsupportedOSPlatform attributes down to the accessor

Co-authored-by: Mitchell Hwang <mitchell.hwang@microsoft.com>
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-System.Console
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants