Skip to content

Improve custom attribute decoding tests #16552

Open

Description

@nguerrera

Currently, due to lack of time, some tests just check that we don't throw. A better approach would probably be to generically compare reflection CustomAttributeData to S.R.M CustomAttributeValue for every test attribute applied.

Also, there needs to be test cases for malformed custom attributes. Test coverage is at ~70% now with only positive cases.

Activity

  1. self-assigned this
    on Mar 1, 2016
  2. changed the title [-]Assert correctness of all custom attribute decoding tests[/-] [+]Improve custom attribute decoding tests[/+] on Mar 1, 2016
  3. YongseopKim commented on Sep 13, 2017

    @YongseopKim
    Contributor

    Anyone has worked for this issue? I'm facing the wrong tc in System.Reflection.Metadata.Tests. (https://github.com/dotnet/corefx/issues/23937).
    In short, the tc System.Reflection.Metadata.Decoding.Tests.CustomAttributeDecoderTests.TestCustomAttributeDecoder supposes that the first elem of reader.GetCustomAttributes(typeDefHandle) is [Test] which has no arguments. Contents of CustomAttributes are same to each other but orders of CustomAttributes are different. Therefore, I think the tc should be fixed to care unsorted CustomAttributes.

    This question has related the problem.

  4. transferred this issue fromdotnet/corefxon Jan 31, 2020
  5. added this to the Future milestone on Jan 31, 2020
  6. removed
    untriagedNew issue has not been triaged by the area owner
    on Jun 29, 2020
  7. buyaa-n commented on Aug 3, 2022

    @buyaa-n
    Contributor

    Updated tests with #72561. There is some inconsistency when Enum type used for constructor argument or named parameter. Most likely related to:

    Type runtimeType = Type.GetType(type.Replace('/', '+')); // '/' vs '+' is only difference between ilasm and reflection notation for fixed set below.

    Because sometimes it produces System.Reflection.Metadata.Decoding.Tests.CustomAttributeDecoderTests+SByteEnum or sometimes System.Reflection.Metadata.Decoding.Tests.CustomAttributeDecoderTests/SByteEnum

    Leaving this issue open to investigate that, some of the test attributes that causing this issue are commented out with reference to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions