SharpScss icon indicating copy to clipboard operation
SharpScss copied to clipboard

A second call to ConvertFilesToCss ignores the filename parameter.

Open leotohill opened this issue 3 years ago • 1 comments

Repro with this Powershell

Add-Type -AssemblyName (Join-Path $runFolder "SharpScss.dll") 
$options = new-object SharpScss.ScssOptions
$options.OutputStyle = [SharpScss.ScssOutputStyle] "Expanded"
$r1= [SharpScss.Scss]::ConvertFileToCss("file1.css",  $options)
# the next line does NOT compile file2.css.  It compiles file1.css.
$r2= [SharpScss.Scss]::ConvertFileToCss("file2.css",  $options)

The cause of the problem is that the first call had options.InputFile set to null, and SharpScss changed that value to "file1.css". Then the second call was specifying the filename in two ways: options.InputFile and the filename parameter to the call. SharpCss chose the options.FIleName value instead of the parameter value.

IMO:

  1. SharpScss should not change values in the Options object. If it needs to do so for internal convenience, it should clone the options and modify the clone
  2. If options.InputFile and the filename parameter to the call specify different non-null values, an exception should be thrown.

leotohill avatar Sep 14 '22 17:09 leotohill

PR with test welcome.

xoofx avatar Sep 15 '22 06:09 xoofx