Skip to content
Draft
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 @@ -19,6 +19,7 @@ namespace Castle.DynamicProxy.Tests
using System.IO;

using NUnit.Framework;
using NUnit.Framework.Internal;

public class FindPeVerify
{
Expand Down Expand Up @@ -117,7 +118,10 @@ public bool IsVerificationDisabled
[TearDown]
public virtual void TearDown()
{
if (IsVerificationPossible && !IsVerificationDisabled)
var currentTest = TestExecutionContext.CurrentContext.CurrentTest;
bool shouldSkipVerificationForCurrentTest = currentTest.Method.IsDefined<SkipPEVerifyAttribute>(false);

if (IsVerificationPossible && !IsVerificationDisabled && !shouldSkipVerificationForCurrentTest)
{
// Note: only supports one generated assembly at the moment
var path = ((PersistentProxyBuilder)builder).SaveAssembly();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2004-2021 Castle Project - http://www.castleproject.org/
// Copyright 2004-2026 Castle Project - http://www.castleproject.org/
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -74,6 +74,7 @@ public void Fully_supported_Not_optional()
Assert.IsAssignableFrom(coreLibDBNullType, proxiedParameter.DefaultValue);
}

[SkipPEVerify(Reason = "no need to verify `HasDefaultValues` proxy type multiple times, it already gets verified in another test")]
[TestCase(nameof(HasDefaultValues.Bool_default))]
[TestCase(nameof(HasDefaultValues.Bool_non_default))]
[TestCase(nameof(HasDefaultValues.Bool_nullable_null))]
Expand Down Expand Up @@ -200,6 +201,7 @@ public void Not_supported_on_the_CLR_Generics(Type parameterType)
}

[Platform(Exclude = "Net,NetCore", Reason = "ParameterBuilder.SetConstant does not accept a null default value for value type parameters. See https://github.com/dotnet/corefx/issues/26164.")]
[SkipPEVerify(Reason = "no need to verify `HasDefaultValues` proxy type multiple times, it already gets verified in another test")]
[TestCase(nameof(HasDefaultValues.DateTime_default))]
[TestCase(nameof(HasDefaultValues.UserDefinedStruct_default))]
public void Not_supported_on_the_CLR_Struct_default(string methodName)
Expand All @@ -208,6 +210,7 @@ public void Not_supported_on_the_CLR_Struct_default(string methodName)
}

[Platform(Exclude = "Net,NetCore", Reason = "ParameterBuilder.SetConstant does not accept non-null default values for nullable enum parameters. See https://github.com/dotnet/coreclr/issues/17893.")]
[SkipPEVerify(Reason = "no need to verify `HasDefaultValues` proxy type multiple times, it already gets verified in another test")]
[TestCase(nameof(HasDefaultValues.UserDefinedEnum_nullable_default))]
[TestCase(nameof(HasDefaultValues.UserDefinedEnum_nullable_default_from_attribute))]
[TestCase(nameof(HasDefaultValues.UserDefinedEnum_nullable_non_default))]
Expand All @@ -218,6 +221,7 @@ public void Not_supported_on_the_CLR_UserDefinedEnum_nullable_non_null(string me
}

[Platform(Exclude = "Mono", Reason = "ParameterInfo.DefaultValue does not report the correct default value for non-null optional parameters of type `DateTime?` and `decimal?`. See https://github.com/mono/mono/issues/11303.")]
[SkipPEVerify(Reason = "no need to verify `HasDefaultValues` proxy type multiple times, it already gets verified in another test")]
[TestCase(nameof(HasDefaultValues.DateTime_nullable_default_from_attribute))]
[TestCase(nameof(HasDefaultValues.DateTime_nullable_non_default_from_attribute))]
[TestCase(nameof(HasDefaultValues.Decimal_nullable_default))]
Expand Down
26 changes: 26 additions & 0 deletions src/Castle.Core.Tests/DynamicProxy.Tests/SkipPEVerifyAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2004-2026 Castle Project - http://www.castleproject.org/
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#nullable enable

namespace Castle.DynamicProxy.Tests
{
using System;

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class SkipPEVerifyAttribute : Attribute
{
public string? Reason { get; set; }
}
}