cecil icon indicating copy to clipboard operation
cecil copied to clipboard

ModuleDefinition.cs Mixin.GetFullyQualifiedName returns empty strings, breaking callers

Open kg opened this issue 14 years ago • 1 comments

    public static string GetFullyQualifiedName (this Stream self)
    {
#if !SILVERLIGHT
        var file_stream = self as FileStream;
        if (file_stream == null)
            return string.Empty;

        return Path.GetFullPath (file_stream.Name);
#else
        return string.Empty;
#endif
    }

This method is used in some parts of Cecil to get the path of an assembly. Returning string.Empty ends up causing a confusing exception later on when the return value is used. It'd be much easier to debug failures caused by this function if it threw instead. Alternately, return null, since an empty string is never a valid path anyway.

Note: I only ran into this because Visual Studio helpfully set the build configuration for Cecil to windows phone instead of Native. Regardless, confusing to debug because of the empty string.

kg avatar Oct 25 '11 04:10 kg

Yup, makes sense.

jbevain avatar Oct 25 '11 07:10 jbevain