thomasgalliker / ValueConverters.NET

A collection of commonly used IValueConverters for .NET applications
MIT License
148 stars 25 forks source link

[Bug]The Debug.WriteLine in DebugConverter was deleted in the Nuget Package #44

Closed zmrbak closed 1 month ago

zmrbak commented 1 year ago

Source Code:

namespace ValueConverters { public class DebugConverter : SingletonConverterBase { protected override object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { Debug.WriteLine("DebugConverter.Convert(value={0}, targetType={1}, parameter={2}, culture={3}", value ?? "null", (object)targetType ?? "null", parameter ?? "null", (object)culture ?? "null");

        return value;
    }

    protected override object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        Debug.WriteLine("DebugConverter.ConvertBack(value={0}, targetType={1}, parameter={2}, culture={3}",
             value ?? "null",
             (object)targetType ?? "null",
             parameter ?? "null",
             (object)culture ?? "null");

        return value;
    }
}

}

The Decompiled code of DebugConverter in the Nuget Package:

namespace ValueConverters { public class DebugConverter : SingletonConverterBase { protected override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return value; }

    protected override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return value;
    }
}

}

thomasgalliker commented 1 year ago

Ahhh. I see the problem. We compile in RELEASE mode which removes all calls to Debug.*

I think we can use something similar to what‘s proposed here: https://stackoverflow.com/a/9987984

thomasgalliker commented 1 month ago

I created another converter TraceConverter which uses Trace.WriteLine instead of Debug.WriteLine. See #55.