sonygod / sharpkit

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

SharpKit parent method resolve warning #178

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
//StringHelpers.cs (namespace/project A)
[JsType(JsMode.Clr, Filename = "js/Helpers.js", NativeParams=false)]
public static class StringHelpers
{
    public static string[] ToArrayOfLines(this string str)
    {
        return str.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray();
    }
}

//ValuesStrings_Partial.cs (namespace/project B)
[JsType(JsMode.Clr, Filename = "js/ValuesStrings.js")]
public static class DictionaryValuesStrings
{   
    public const string Countries = "UNITED STATES\tUS";
}

//FieldValues.cs (namespace/project B)
[JsType(JsMode.Clr, Filename = "js/AddressParser.js")] 
public static class FieldValues 
{
    private static Dictionary<string, string> TurnIntoDictionary(string str) 
    { 
        return str.ToArrayOfLines() 
         .Select<string, string[]>(x => x.Split(new char[] { '\t' }))
         .ToDictionarySharpKit<string[], string, string>(x => x[0], x => x[1]);  //ToDictionary not SharpKit-supported
    }
    internal static readonly Dictionary<string, string> Countries = 
        TurnIntoDictionary(DictionaryValuesStrings.Countries); 

    internal static readonly Dictionary<string, string> CountriesReverse = 
        Countries.GroupByValue() //GroupBy not Sharpkit-supported
/***/    .ToDictionary(x => x.Key, x => x.Value.First().Key);
}

//file3.cs (namespace/project A)
[JsType(JsMode.Clr, Filename = "js/Helpers.js")] 
public static class GenericHelpers 
{
        public static Dictionary<TKey, TElement> ToDictionarySharpKit<TSource, TKey, TElement>(
            this IEnumerable<TSource> source,
            Func<TSource, TKey> keySelector,
            Func<TSource, TElement> elementSelector)
        {
            var dict = new Dictionary<TKey, TElement>();
            foreach (var e in source)
                dict.Add(keySelector(e), elementSelector(e));
            return dict;
        }

        public static IDictionary<TValue, IEnumerable<KeyValuePair<TKey, TValue>>> GroupByValue<TKey, TValue>(
                this IDictionary<TKey, TValue> dict)
        {
            IDictionary<TValue, IEnumerable<KeyValuePair<TKey, TValue>>> groupedDict = new Dictionary<TValue, IEnumerable<KeyValuePair<TKey, TValue>>>();
            foreach (TValue i in dict.Values.Distinct())
            {
                groupedDict.Add(i, dict.Where(x => x.Value.Equals(i)));
            }
            return groupedDict;
        }
}

Original issue reported on code.google.com by DanelK...@gmail.com on 4 Aug 2012 at 6:24

GoogleCodeExporter commented 9 years ago
The problem arises when using lambda expressions in field initializers.

Original comment by DanelK...@gmail.com on 4 Aug 2012 at 6:39