Skip to content

Commit a8743aa

Browse files
committed
Tolerate missing assembly attributes
- mainly for third party builds that neglect to add the attributes - see #495
1 parent 86f0d2b commit a8743aa

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

crypto/src/bcpg/ArmoredOutputStream.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,14 @@ private static void Encode3(Stream outStream, byte[] data)
133133
private static string CreateVersion()
134134
{
135135
var assembly = Assembly.GetExecutingAssembly();
136-
var title = assembly.GetCustomAttribute<AssemblyTitleAttribute>().Title;
137-
var version = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
138-
return title + " v" + version;
136+
137+
var titleAttr = assembly.GetCustomAttribute<AssemblyTitleAttribute>();
138+
var versionAttr = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
139+
140+
if (titleAttr == null || versionAttr == null)
141+
return "BouncyCastle (unknown version)";
142+
143+
return titleAttr.Title + " v" + versionAttr.InformationalVersion;
139144
}
140145

141146
private static readonly string Version = CreateVersion();

0 commit comments

Comments
 (0)