Repository navigation
Closed
Labels
Milestone
Description
We can use UnsupportedOSPlatformAttribute("browser") attribute to mark unsupported APIs on Browser WASM so that the analyzer can provide warnings when developers accidentally call platform-specific APIs.
Spec: dotnet/designs#144
We use the scanner (https://github.com/dotnet/platform-compat) to gather the list of all the APIs throwing PNSE on Browser WASM at the moment. Below is the file containing ~4500 PNSE methods.
pnse-17082020.txt
There can be some special cases:
- APIs can be Windows-specific
- APIs might throw PNSE for all platforms
- APIs might not be considered to be marked (e.g. APIs are not meant to be directly called by user code)
- other cases?
Namespaces (L# in file above)
- Microsoft.VisualBasic L2-L45 (marked as Windows-specific)
- System.Security.AccessControl L46-65 (marked as Windows-specific)
- Microsoft.Win32.Registry L66-106 (marked as Windows-specific)
- System.Collections L107-L110 (
Mark some System.Collection APIs as unsupported on Browser WASM #41085) serialization-related infrastructure - System.Collections.Specialize L111-L114 (
Mark some System.Collection APIs as unsupported on Browser WASM #41085) serialization-related infrastructure - System.ComponentModel L115-L120 ([wasm] Mark System.ComponentModel APIs as unsupported on Browser #41094) backport [release/5.0] Backport Browser Unsupported Attribute Changes #41967
- System.Console L121-L172 ([wasm] Mark System.Console APIs as unsupported on Browser #41184) backport [release/5.0] Backport Browser Unsupported Attribute Changes #41967
- System.Data.Common L173-L178 (
[wasm] Mark System.Data.Common APIs as unsupported on Browser #41263) false-positive, obsolete, serialization related - System.Data.Odbc ([browser] Mark APIs as unsupported on browser #40612) No backport necessary
- System.Diagnostics.FileVersionInfo L179-L207 (Mark System.Diagnostics.FileVersionInfo as unsupported on Browser #41271) backport [release/5.0] Backport Browser Unsupported Attribute Changes #41967
- System.Diagnostics.Process L208-L388 ([wasm] Mark System.Diagnostics.Process APIs as unsupported on Browser #41694) backport [release/5.0] Backport Browser Unsupported Attribute Changes #41967
- System.Diagnostics.TextWriterTraceListener L389-L393 (
[wasm] Mark System.Diagnostics.XmlWriterTraceListener APIs as unsupported on Browser #41327) False Positive - System.DirectoryServices.Protocols ([browser] Mark APIs as unsupported on browser #40612) No backport necessary
- System.Drawing.Common ([browser] Mark APIs as unsupported on browser #40612) No backport necessary
- System.IO.Compression L394-429 ([wasm] Mark System.IO.Compression APIs as unsupported on Browser #41683) backport [release/5.0] Backport Browser Unsupported Attribute Changes #41967
- System.IO.FileSystem.AccessControl L430-L489 (marked as Windows-specific)
- System.IO.FileSystem L490-L495 (marked as Windows-specific)
- System.IO.FileSystem.DriveInfo L496-L497 (
[wasm] Mark System.IO.FileSystem.DriveInfo APIs as unsupported on Browser #41328) - System.IO.FileSystem.Watcher L498-L547 ([wasm] Mark System.IO.FileSystem.Watcher APIs as unsupported on Browser #41682) backport [release/5.0] Backport Browser Unsupported Attribute Changes #41967
- System.IO.IsolatedStorage L548-L647 ([wasm] Mark System.IO.IsolatedStorage APIs as unsupported on Browser #41700) backport [release/5.0] Backport Browser Unsupported Attribute Changes #41967
- System.IO.MemoryMappedFiles L648-L662 (
[wasm] Mark System.IO.MemoryMappedFiles APIs unsupported on browser #41971) false-positive - System.IO.Pipes L663-L778 (Mark System.IO.Pipes Unsupported at assembly level #41976) backport [release/5.0-rc2] Backport Additional Browser Unsupported Attribute Changes #42267
- System.IO.Ports ([browser] Mark APIs as unsupported on browser #40612) No backport necessary
- System.Linq.Expressions L779 (marked as obsolete)
- System.Linq.Queryable L780-L782 (
Mdhwang/system linq queryable unsupported #41330) False Positive - System.Net.Connections L783 (the namespace is being removed; see PRs 41648 and 42099)
- System.Net.Http L784-L872 (Mark some System.Net.Http APIs as unsupported on browser #42074) backport [release/5.0-rc2] Backport Additional Browser Unsupported Attribute Changes #42267
- System.Net.HttpListener L873-L883 (Mark some System.Net.HttpListener APIs as unsupported on browser #42063) backport [release/5.0-rc2] Backport Additional Browser Unsupported Attribute Changes #42267
- System.Net.Mail L884-L1083 (Mark some APIs as unsupported on Browser WASM #40924) backport [release/5.0] Backport Browser Unsupported Attribute Changes #41967
- System.Net.NameResolution L1084-L1109 ([wasm] Mark System.Net.NameResolution Unsupported at assembly level #41985) backport [release/5.0] Backport Browser Unsupported Attribute Changes #41967
- System.Net.NetworkInformation L1110-L1208 (Mark some APIs as unsupported on Browser WASM #40924) backport [release/5.0] Backport Browser Unsupported Attribute Changes #41967
- System.Net.Ping L1209-L1250 (Mark some APIs as unsupported on Browser WASM #40924) backport [release/5.0] Backport Browser Unsupported Attribute Changes #41967
- System.Net.Primitives L1251-L1255 (
[wasm] Mark System.Net.SocketAddress APIs unsupported on Browser #41987) false-positive - System.Net.Requests L1256-L1600 (Mark some APIs as unsupported on Browser WASM #40924) backport [release/5.0] Backport Browser Unsupported Attribute Changes #41967
- System.Net.Security L1601-L1828 (Mark some APIs as unsupported on Browser WASM #40924) backport [release/5.0] Backport Browser Unsupported Attribute Changes #41967
- System.Net.Sockets L1829-L2240 (Mark some APIs as unsupported on Browser WASM #40924) backport [release/5.0] Backport Browser Unsupported Attribute Changes #41967
- System.Net.Webclient L2241-L2374 (Mark some APIs as unsupported on Browser WASM #40924) backport [release/5.0] Backport Browser Unsupported Attribute Changes #41967
- System.Net.WebHeaderCollection L2375-L2377 Serialization Infrastructure
- System.Net.WebProxy L2378-L2383 obsolete/all platforms/serialization-related infrastructure
- System.Net.WebSockets.Client L2384-L2400 (Mark System.Net.WebSockets.ClientWebSocketOptions APIs as unsupported on Browser #41963) backport [release/5.0] Backport Browser Unsupported Attribute Changes #41967
- System.Net.WebSockets L2401 PNSE everywhere
- System.Runtime L2402-L2424, L2445-L2467 (
Mark System.Runtime APIs Supported on Windows #42030) False-positives/PNSE all mono/windows only - System.Utf8String.Experimental L2425-L2444, L2507-L2523 likely false positive
- System.Threading.Thread L2468-L2474, L2497 (
[wasm] Mark System.Threading.Thread APIs unsupported on Browser #41892) - System.Threading.ThreadPool L2475-L2484, L2490 ([wasm] Mark System.Threading.ThreadPool unsupported on Browser #41891) backport [release/5.0] Backport Browser Unsupported Attribute Changes #41967
- System.Threading L2485-L2489, L2496, L2498-L2499 (
[wasm] Mark System.Threading APIs as unsupported on Browser #41888) - System.Threading.Overlapped L2491-L2495 (
[wasm] Mark System.Threading.ThreadPoolBoundHandle unsupported on Browser #41884) windows-specific - System.Private.CoreLib L2500-L2506, L2524-L2600 False-positives/Serialization-related/PNSE all platforms
- System.Runtime.Serialization.Xml L2601-L2617 (all platforms)
- System.Private.Xml L2618 false-positive
- System.Private.Xml.Linq L2619 serialization-related infrastructure
- System.Reflection.DispatchProxy L2620 false-positive (DispatchProxyTests.cs tests pass)
- System.Resources.Writer L2621-L2623 false-positives (ResourceWriterUnitTest.cs passes)
- System.Runtime.InteropServices L2624-L2625 (windows-specific), 2626-2628 (all platforms)
- System.Runtime.Serialization.Formatters L2629-L2630 obsolete
- System.Security.AccessControl L2631-L2909 windows-specific
- System.Security.Claims L2910-2915 (all platforms)
- System.Secuirty.Cryptography L2916-L3464 (Mark System.Security.Cryptography.Algorithms as unsupported on Browser WASM #42010) backport [release/5.0-rc2] Backport Additional Browser Unsupported Attribute Changes #42267
- System.Security.Cryptography.Cng L3465-L3716 windows-specific
- System.Security.Cryptography.Csp L3717-L3895 ([browser] Mark APIs as unsupported on browser #40612) No backport necessary
- System.Security.Cryptography.Encoding L3896-L3974 ([browser] Mark APIs as unsupported on browser #40612) No backport necessary
- System.Security.Cryptography.OpenSsl L3975-L4034([browser] Mark APIs as unsupported on browser #40612) No backport necessary
- System.Security.Cryptography.Pkcs ([browser] Mark APIs as unsupported on browser #40612) No backport necessary
- System.Security.Cryptography.Primitives L4035-L4045([browser] Mark APIs as unsupported on browser #40612) No backport necessary
- System.Security.Cryptography.X509Certificates L4046-4375([browser] Mark APIs as unsupported on browser #40612) No backport necessary
- System.Security.Cryptography.Xml ([browser] Mark APIs as unsupported on browser #40612) No backport necessary
- System.Security.Principal.Windows L4376-L4471 windows-specific
- System.Text.Encodings.Web L4472 Looks like a false-positive
- System.Text.Json L4473-L4494 Looks like false-positives
- System.Text.RegularExpressions L4495-L4499 Looks like false-positives
- System.Transactions.Local L4500-4509 (
[wasm] Mark System.Transactions.Local APIs unsupported on browser #42027) PNSE all platforms
Activity
Dotnet-GitSync-Bot commentedon Aug 20, 2020
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
CoffeeFlux commentedon Aug 21, 2020
area-VM-meta-mono seems like the wrong area for this since it's purely libraries, but I'm not sure what to use for something that applies to libraries as a whole. area-Meta also seems wrong...
akoeplinger commentedon Aug 24, 2020
@jeffhandley @adamsitnik while adding the
[UnsupportedOSPlatform]attributes to the src a question came up what to do when the method we're annotating has multiple implementations (e.g. .Browser.cs, .Unix.cs and .Windows.cs).Should we add the attribute to all the implementations in those cases? If we don't do that then regenerating the ref would remove the attribute if you're on a different platform.
jeffhandley commentedon Aug 24, 2020
I've been encountering similar stuff with #41209, where we're trying to get the runtime repo ready to receive the analyzer. We don't yet have a solid strategy for this scenario.
adamsitnik commentedon Aug 25, 2020
This is what we have been doing so far.
jeffhandley commentedon Aug 26, 2020
We have now filed #41354 against the runtime repo to resolve the issues there for RC2.
MaximLipnin commentedon Sep 16, 2020
It looks like the exception scanner doesn't gather PNSEs thrown from runtime, e.g. something that uses
mono_error_set_platform_not_supportedmethod. At least, I don't see appropriate APIs in the result file attached to the PR's description. In case of Browser, an example of such API could be Thread.Start() which invokesStartInternal -> ves_icall_System_Threading_Thread_StartInternal -> mono_error_set_platform_not_supported.sigmarsson commentedon May 5, 2021
Hi Seniors, Is there an alternative way to retrieve assembly version info on Wasm instead of
FileVersionInfo?That is not supported any more in the browser.
unoplatform/uno#5916
marek-safar commentedon May 5, 2021
@sigmarsson what about using
RuntimeEnvironment.GetSystemVersion ()?sigmarsson commentedon May 5, 2021
@marek-safar i wish to retrieve either the calling or the executing assembly version.
sigmarsson commentedon May 5, 2021
E.g.
marek-safar commentedon May 5, 2021
I see, in that case, the closest approximation would be to read System.Reflection.AssemblyFileVersionAttribute from the assembly.
MaximLipnin commentedon May 12, 2021
All the namespaces mentioned in this issue are covered so I'm closing it as completed