Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

Add static JsConsole class to expose the various console methods available in Javascript #396

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

jon-hall
Copy link
Contributor

@jon-hall jon-hall commented Mar 3, 2015

Addresses #379.

Not 100% thrilled with the tests and would be willing to improve if you have any preference on a different testing strategy, but this is a difficult thing to confirm it works as expected through unit testing without potentially missing other issues as a result.

Jon Hall added 2 commits March 3, 2015 14:37
…lable in Javascript.

Add polyfills for the (non-standard) methods found on console, to prevent errors (and provide some functionality) in browsers which don't support them.
…lable in Javascript.

Add polyfills for the (non-standard) methods found on console, to prevent errors (and provide some functionality) in browsers which don't support them.
@jon-hall
Copy link
Contributor Author

jon-hall commented Mar 4, 2015

I placed this in a separate class just because it deviates significantly from the .NET Console API, though I can transplant the code the System.Console if you'd prefer.

As for the polyfills, I can't seem to find any info on what your intended browser support/language level support for the Javascript produced by Saltarelle is and just took a nod from the fact that there are some Array#extras polyfills in mscorlib. I'm happy to remove the polyfills though if this library isn't specifically intended to produce code that can run unaided on older browsers.

@erik-kallen
Copy link
Contributor

The policy is that mscorlib contains the polyfills required for mscorlib to work (but I am inclined to think that it should not depend on those methods of which I think there are 2).

I don't think it hurts to have the methods in System.Console, since all the methods are static and only add to the .net API, so source compatibility should not be an issue.

@jon-hall
Copy link
Contributor Author

jon-hall commented Mar 4, 2015

Yeah, the only issue with compatibility (when placing these methods on System.Console) would be the ability to compile a Saltarelle project as C# into a .dll, though there are already API extensions to some of the mscorlib classes which prevent such an action as far as I can tell.

I'll get a commit pushed up that drops the polyfills and relocates the methods onto System.Console.

Move JsConsole methods onto System.Console.
@thargy
Copy link

thargy commented Mar 6, 2015

It does seem a shame to merge System.Console with a separate JsConsole. I'm not really sure what the benefit is, but the disadvantage is that you can't as easily target both .Net and JS without using #if blocks. Having System.Console standard methods write to the browser console is great, but where there are different methods for the browser console, if feels nicer to have these in a separate class, as they are not really part of CLR or BCL. IMHO

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants