<commit_before>﻿using System;
using System.Reflection;
using System.Runtime.InteropServices;
using ApiCheck.Result;
using ApiCheck.Result.Difference;
using ApiCheck.Utility;

namespace ApiCheck.Comparer
{
  internal class FieldComparer : ComparerBase<FieldInfo>
  {
    public FieldComparer(FieldInfo referenceType, FieldInfo newType, IComparerContext comparerContext)
      : base(referenceType, newType, comparerContext, ResultContext.Field, referenceType.ToString())
    {
    }

    public override IComparerResult Compare()
    {
      ComparerContext.LogDetail(string.Format("Comparing field '{0}'", ReferenceType));
      if (ReferenceType.FieldType.GetCompareableName() != NewType.FieldType.GetCompareableName())
      {
        ComparerResult.AddChangedProperty("Type", ReferenceType.FieldType.GetCompareableName(), NewType.FieldType.GetCompareableName(), Severity.Error);
      }
      if (ReferenceType.IsStatic != NewType.IsStatic)
      {
        ComparerResult.AddChangedFlag("Static", ReferenceType.IsStatic, Severity.Error);
      }
      if (ReferenceType.IsStatic && NewType.IsStatic && ReferenceType.FieldType.IsEnum)
      {
        // compare numeric enum values
        object referenceValue = ReferenceType.GetValue(null);
        object newValue = NewType.GetValue(null);
        if (Convert.ToInt32(referenceValue) != Convert.ToInt32(newValue))
        {
          ComparerResult.AddChangedProperty("Value", referenceValue.ToString(), newValue.ToString(), Severity.Error);
        }
      }
      return ComparerResult;
    }
  }
}<commit_msg>enum value comparison now also works with ReflectionOnly loaded assemblies<commit_after>﻿using System;
using System.Reflection;
using System.Runtime.InteropServices;
using ApiCheck.Result;
using ApiCheck.Result.Difference;
using ApiCheck.Utility;

namespace ApiCheck.Comparer
{
  internal class FieldComparer : ComparerBase<FieldInfo>
  {
    public FieldComparer(FieldInfo referenceType, FieldInfo newType, IComparerContext comparerContext)
      : base(referenceType, newType, comparerContext, ResultContext.Field, referenceType.ToString())
    {
    }

    public override IComparerResult Compare()
    {
      ComparerContext.LogDetail(string.Format("Comparing field '{0}'", ReferenceType));
      if (ReferenceType.FieldType.GetCompareableName() != NewType.FieldType.GetCompareableName())
      {
        ComparerResult.AddChangedProperty("Type", ReferenceType.FieldType.GetCompareableName(), NewType.FieldType.GetCompareableName(), Severity.Error);
      }
      if (ReferenceType.IsStatic != NewType.IsStatic)
      {
        ComparerResult.AddChangedFlag("Static", ReferenceType.IsStatic, Severity.Error);
      }
      if (ReferenceType.IsStatic && NewType.IsStatic && ReferenceType.FieldType.IsEnum)
      {
        // compare numeric enum values
        object referenceValue = ReferenceType.GetRawConstantValue();
        object newValue = NewType.GetRawConstantValue();
        if (Convert.ToInt32(referenceValue) != Convert.ToInt32(newValue))
        {
          ComparerResult.AddChangedProperty("Value", referenceValue.ToString(), newValue.ToString(), Severity.Error);
        }
      }
      return ComparerResult;
    }
  }
}
{'fraction_non_alphanumeric': 0.10152600436001245, 'fraction_numerical': 0.003114294612270321, 'mean_word_length': 3.972136222910217, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6939904', 'n_tokens_mistral': 876, 'n_tokens_neox': 872, 'n_words': 157}