Skip to content

Commit

Permalink
5 test case arguments dont parse for release dll builds (#8)
Browse files Browse the repository at this point in the history
* #5 corrected argument parsing depending on built DLL configuration

* Added debugging #5

* #5 more logging and checking
  • Loading branch information
gubpalma authored Apr 8, 2024
1 parent cc140ca commit 170595a
Showing 1 changed file with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,31 +156,50 @@ public SpecFlowAssembly ExtractFeatures(AssemblyDefinition assembly)

private bool IsDebugBuild(ICustomAttributeProvider assembly)
{
_logger
.LogDebug($"Loading custom attributes for assembly");

var customAttributes =
assembly
.CustomAttributes;
(assembly?
.CustomAttributes ?? Enumerable.Empty<CustomAttribute>())
.ToList();

_logger
.LogDebug($"Custom attributes loaded [{customAttributes.Count}]");

var debuggableAttribute =
(customAttributes ?? Enumerable.Empty<CustomAttribute>())
customAttributes
.FirstOrDefault(o => o.AttributeType.FullName == typeof(DebuggableAttribute).FullName);

if (debuggableAttribute != null)
{
_logger
.LogDebug($"DebuggableAttribute found");

var debuggingMode =
debuggableAttribute
.ConstructorArguments
(debuggableAttribute
.ConstructorArguments ?? Enumerable.Empty<CustomAttributeArgument>())
.FirstOrDefault(o => o.Type.FullName == DebuggingModeAttributeName);

if (debuggingMode.Value != null)
{
_logger
.LogInformation($"Debugging attribute value: [{debuggingMode.Value}]");

var flagValue =
debuggingMode
.Value?
.ToString();

if (string.IsNullOrEmpty(flagValue))
return false;

var attributes =
(DebuggableAttribute.DebuggingModes)Enum.Parse(
typeof(DebuggableAttribute.DebuggingModes),
(debuggingMode.Value ?? string.Empty).ToString()
flagValue
);

return
attributes
.HasFlag(DebuggableAttribute.DebuggingModes.Default);
Expand Down

0 comments on commit 170595a

Please sign in to comment.