sonygod / sharpkit

Automatically exported from code.google.com/p/sharpkit
0 stars 0 forks source link

string.format with arguments v4.27.4000/v5 beta #136

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

var test = string.Format("test {0}", 1);
inside btnTest_click on a default v4.27.4000 project v5 beta project

  SharpKit.Compiler.CompilerException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. ---> System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
     at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
     at System.String.Format(IFormatProvider provider, String format, Object[] args)
     at System.String.Format(String format, Object[] args)
     at SharpKit.Compiler.CompilerLogger.WriteLine(String s)
     at SharpKit.Compiler.JsCodeImporter.Visit(ResolveResult res)
     --- End of inner exception stack trace ---
     at SharpKit.Compiler.JsTypeImporter.Visit(IEntity node)
     at SharpKit.Compiler.JsModelImporter.ExportType(ITypeDefinition ce)
     at SharpKit.Compiler.JsModelImporter.ExportType(ITypeDefinition ce, JsFile jsFile)
     at SharpKit.Compiler.JsModelImporter.<>c__DisplayClassb.<ExportTypesInFile>b__a(ITypeDefinition t)
     at System.Collections.Generic.List`1.ForEach(Action`1 action)
     at SharpKit.Compiler.JsModelImporter.ExportTypesInFile(KeyValuePair`2 p)
     at System.Linq.Extensions.ForEach[T](IEnumerable`1 items, Action`1 action)
     at SharpKit.Compiler.JsModelImporter.Process()
     at SharpKit.Compiler.CompilerTool.ConvertCsToJs()
     at SharpKit.Compiler.CompilerTool.Time(Action action)
     at SharpKit.Compiler.CompilerTool.Run()

This compiles on in default v4.27.4000 project. 

Original issue reported on code.google.com by co...@gravill.com on 28 May 2012 at 11:53

GoogleCodeExporter commented 9 years ago
This exact example seem to work fine, I suspect this bug occurs when the 
compiler logger tries to log an error related to this line. Do you have a 
reproducible example?

Original comment by DanelK...@gmail.com on 29 May 2012 at 9:03

GoogleCodeExporter commented 9 years ago
That reproducibly fails for me on a new project, the complete code

using SharpKit.JavaScript;
using SharpKit.Html4;
using SharpKit.jQuery;

namespace SharpKitWebApp4
{
    [JsType(JsMode.Global, Filename = "res/Default.js")]
    public class DefaultClient : jQueryContextBase
    {
        static void DefaultClient_Load()
        {
            J(document.body).append("Ready<br/>");
        }
        static void btnTest_click(HtmlDomEventArgs e)
        {
            J(document.body).append("Hello world<br/>");

            var test = string.Format("test {0}", 1);
        }
    }
}

I've attached my config and log in case that helps.

Original comment by co...@gravill.com on 29 May 2012 at 9:18

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks, found it, happens when logging is enabled, fixed.

Original comment by DanelK...@gmail.com on 29 May 2012 at 9:54