This project is read-only.
1

Closed

New constructor to be able to inject a ErrorReporter

description

I've noticed you've started adding support for a CustomErrorReporter property in JavaScriptCompressor. Although nice to be able to change the errorReporter it will not be enough to set it thru a property. Since parsing is performed in the constructor, setting the CustomErrorReporter property will be possible AFTER parsing, i.e. to late. Instead, the errorReporter should be injected in the constructor. Remove the CustomErrorReporter property and add the following constructor:
 
public JavaScriptCompressor(string javaScript, bool isVerboseLogging, Encoding encoding, CultureInfo threadCulture, ErrorReporter errorReporter)
{
if(string.IsNullOrEmpty(javaScript))
{
    throw new ArgumentNullException("javaScript");
}
 
// Lets make sure the current thread is in english. This is because most javascript (yes, this also does css..)
// must be in english in case a developer runs this on a non-english OS.
// Reference: http://www.codeplex.com/YUICompressor/WorkItem/View.aspx?WorkItemId=3219
Thread.CurrentThread.CurrentCulture = threadCulture;
Thread.CurrentThread.CurrentUICulture = threadCulture;
 
Initialise();
 
this._verbose = isVerboseLogging;
 
MemoryStream memoryStream = new MemoryStream(encoding.GetBytes(javaScript));
this._logger = errorReporter;
this._tokens = Parse(new StreamReader(memoryStream),errorReporter);
}
Closed Jul 3, 2009 at 4:28 AM by purekrome
Added and fixed.

comments

purekrome wrote Apr 16, 2009 at 1:23 PM

Assigned to release 1.4.0.0. Cheers for noticing that!

wrote Jul 3, 2009 at 4:28 AM

wrote Feb 22, 2013 at 12:55 AM

wrote May 16, 2013 at 12:20 PM