src/Castle.Core.Tests/CustomModifiersTestCase.cs
/// <summary>
/// This test checks whether reflection correctly reports back the modopts on
/// the parameter type in the generated types.
/// </summary>
This test checks whether reflection correctly reports back the modopts on
the parameter type in the generated types.
This test checks whether reflection correctly reports back the modopts on the parameter type in the generated types .
[TestCaseSource(nameof(AsModoptOnParamTypeNames))]
		public void ReflectionReturnsCorrectModoptOnParamTypeForGeneratedType(string typeName)
		{
			Assume.That(this.generatedTypes.ContainsKey(typeName));
			const string suffix = "_AsModoptOnParamType";
			Assume.That(typeName.EndsWith(suffix));
			var typeNameWithoutSuffix = typeName.Substring(0, typeName.Length - suffix.Length);
			Assume.That(CustomModifiersTestCase.customModifiers.ContainsKey(typeNameWithoutSuffix));
			var modopts = this.generatedTypes[typeName].GetMethod("Foo").GetParameters()[0].GetOptionalCustomModifiers();
			Assume.That(modopts.Length > 0); 
			CollectionAssert.AreEqual(expected: CustomModifiersTestCase.customModifiers[typeNameWithoutSuffix].Reverse(), actual: modopts);
		}
[ TestCaseSource ( nameof ( AsModoptOnParamTypeNames ) ) ] public void ReflectionReturnsCorrectModoptOnParamTypeForGeneratedType ( string typeName ) { Assume . That ( this . generatedTypes . ContainsKey ( typeName ) ) ; const string suffix = " " ; Assume . That ( typeName . EndsWith ( suffix ) ) ; var typeNameWithoutSuffix = typeName . Substring ( 0 , typeName . Length - suffix . Length ) ; Assume . That ( CustomModifiersTestCase . customModifiers . ContainsKey ( typeNameWithoutSuffix ) ) ; var modopts = this . generatedTypes [ typeName ] . GetMethod ( " " ) . GetParameters ( ) [ 0 ] . GetOptionalCustomModifiers ( ) ; Assume . That ( modopts . Length > 0 ) ; CollectionAssert . AreEqual ( expected : CustomModifiersTestCase . customModifiers [ typeNameWithoutSuffix ] . Reverse ( ) , actual : modopts ) ; }
This test checks whether reflection correctly reports back the modopts on
the parameter type in the generated types.
This test checks whether reflection correctly reports back the modopts on the parameter type in the generated types .
// If this fails on mono/linux we have to revisit the commits and issues for IL method custom modifiers. https://github.com/castleproject/Core/issues/277 // ^ The `.Reverse()` is needed because the CLR reports custom modifiers in reverse order. //   Note to future maintainers: Mono either does not report custom modifiers at all, //   or it reports them in the correct order. This needs further investigation, but //   in either case, the above assertion would make the test fail on Mono!
typeName
string