Skip to content

Commit d16a31e

Browse files
authored
Add check for missing AssemblyNativeVersionAttribute (#60)
***NO_CI***
1 parent 395510a commit d16a31e

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

source/MetadataProcessor.Console/Program.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,8 @@ public void GenerateSkeleton(
146146
}
147147
catch (Exception ex)
148148
{
149-
System.Console.Error.WriteLine(
150-
"Unable to generate skeleton files");
151-
152-
Environment.Exit(1);
149+
System.Console.Error.WriteLine("Unable to generate skeleton files.");
150+
throw;
153151
}
154152
}
155153

source/MetadataProcessor.Core/nanoSkeletonGenerator.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,15 @@ private void GenerateAssemblyLookup()
293293
{
294294
// grab native version from assembly attribute
295295
var nativeVersionAttribute = _tablesContext.AssemblyDefinition.CustomAttributes.FirstOrDefault(a => a?.AttributeType?.Name == "AssemblyNativeVersionAttribute");
296+
297+
// check for existing AssemblyNativeVersionAttribute
298+
if (nativeVersionAttribute == null)
299+
{
300+
throw new ArgumentException("Missing AssemblyNativeVersionAttribute." + Environment.NewLine +
301+
"Make sure that AssemblyNativeVersionAttribute is defined in AssemblyInfo.cs, like this:" + Environment.NewLine +
302+
"[assembly: AssemblyNativeVersion(\"1.0.0.0\")]");
303+
}
304+
296305
Version nativeVersion = new Version((string)nativeVersionAttribute.ConstructorArguments[0].Value);
297306

298307
var assemblyLookup = new AssemblyLookupTable()

0 commit comments

Comments
 (0)