Skip to content

Commit fcd219e

Browse files
committed
override ToString for InputFile* classes => (Id, Url, "stream://..")
1 parent 89e38cf commit fcd219e

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/Telegram.Bot/Types/InputFiles/InputFile.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ public InputFileId() { }
7373
/// <summary>Implicit operator, same as <see cref="InputFileId(string)"/>, but returns null for a null string</summary>
7474
[return:NotNullIfNotNull(nameof(fileId))]
7575
public static implicit operator InputFileId?(string? fileId) => fileId is null ? null : new(fileId);
76+
77+
/// <summary>Returns the Id</summary>
78+
public override string ToString() => Id;
7679
}
7780

7881
/// <summary>This object represents the contents of a file to be uploaded. Must be posted using multipart/form-data in the usual way that files are uploaded via the browser</summary>
@@ -100,6 +103,9 @@ public InputFileStream() { }
100103

101104
/// <summary>Implicit operator, same as <see cref="InputFileStream(Stream,string)"/> without given filename</summary>
102105
public static implicit operator InputFileStream(Stream stream) => new(stream);
106+
107+
/// <summary>Returns "stream://realfilename" for a FileStream content, or "stream://0" otherwise</summary>
108+
public override string ToString() => Content is FileStream fs ? "stream://" + Path.GetFileName(fs.Name) : "stream://0";
103109
}
104110

105111
/// <summary>This object represents an HTTP URL for the file to be sent</summary>
@@ -128,4 +134,7 @@ public InputFileUrl() { }
128134

129135
/// <summary>Implicit operator, same as <see cref="InputFileUrl(string)"/></summary>
130136
public static implicit operator InputFileUrl(string url) => new(url);
137+
138+
/// <summary>Returns the Url</summary>
139+
public override string ToString() => Url.ToString();
131140
}

0 commit comments

Comments
 (0)