Skip to content

Fix MVC Core tests for CoreCLR GetCustomAttributes consistency #62872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,14 @@ public void GetMetadataForParameter_SuppliesEmptyAttributes_WhenParameterHasNoAt
// Assert
var defaultMetadata = Assert.IsType<DefaultModelMetadata>(metadata);

// Not exactly "no attributes" due to SerializableAttribute on object.
Assert.IsType<SerializableAttribute>(Assert.Single(defaultMetadata.Attributes.Attributes));
// The parameter itself has no attributes
Assert.Empty(defaultMetadata.Attributes.ParameterAttributes);

// Type attributes exist (but we don't care what they are - that's runtime implementation detail)
Assert.NotEmpty(defaultMetadata.Attributes.TypeAttributes);

// Combined attributes = ParameterAttributes + TypeAttributes (when parameter has no attributes)
Assert.Equal(defaultMetadata.Attributes.TypeAttributes, defaultMetadata.Attributes.Attributes);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,15 @@ public void GetAttributesForParameter_NoAttributes()
.GetParameters()[0]);

// Assert
// Not exactly "no attributes" due to SerializableAttribute on object.
Assert.IsType<SerializableAttribute>(Assert.Single(attributes.Attributes));
// The parameter itself has no attributes
Assert.Empty(attributes.ParameterAttributes);
Assert.Null(attributes.PropertyAttributes);
Assert.Equal(attributes.Attributes, attributes.TypeAttributes);

// Type attributes exist (but we don't care what they are - that's runtime implementation detail)
Assert.NotEmpty(attributes.TypeAttributes);

// Combined attributes = ParameterAttributes + TypeAttributes (when parameter has no attributes)
Assert.Equal(attributes.TypeAttributes, attributes.Attributes);
}

[Fact]
Expand Down
Loading