How can I tell the developer of my frontend that the path parameter is a folder?

I'm going to define an interface in my application that plugins can use to provide custom "export" capabilities. It will look something like this:

public interface IFooExporter
{
    void ExportFoo(Foo foo, string path);
}

      

However, I need the writers to know (explicitly, not just in the documentation) that the "path" is a folder, not a filename. It is their responsibility to create the files as part of the export process.

What's the best way to enforce this path is the folder, not the filename? My best guess right now is to use DirectoryInfo instead of a string:

public interface IFooExporter
{
    void ExportFoo(Foo foo, DirectoryInfo folder);
}

      

Is this a good solution, or are there any bugs I am not aware of with missing DirectoryInfo instances?

0


source to share


3 answers


Since you are not implementing the solution, I agree with you in the decision to use DirectoryInfo as a parameter. If you supply a string, there is no way to stop the passed string.



+1


source


Use XML comments, they will appear in the Visual Studio Intellisense popup.



/// <summary>
/// Type in the text you want to appear
/// </summary>

      

+1


source


Name your variable more explicitly. Is this just the way? You say it isn't, but you leave it with a common name anyway. Name it folderPath and there will be less confusion and less need to explicitly communicate it to the developers.

+1


source







All Articles