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

Open
opened 2011-10-24 23:26:40 -05:00 by kg · 1 comment
kg commented 2011-10-24 23:26:40 -05:00 (Migrated from github.com)
    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.

``` 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.
jbevain commented 2011-10-25 02:19:37 -05:00 (Migrated from github.com)

Yup, makes sense.

Yup, makes sense.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-jbevain/cecil#79
No description provided.