src/Castle.Core.Tests/CustomModifiersTestCase.cs
/// <summary>
/// This test checks whether reflection correctly reports back the modopts on
/// the return type in the generated types.
/// </summary>
This test checks whether reflection correctly reports back the modopts on
the return type in the generated types.
This test checks whether reflection correctly reports back the modopts on the return type in the generated types .
[TestCaseSource(nameof(AsModreqOnReturnTypeNames))]
		public void ReflectionReturnsCorrectModreqOnReturnTypeForGeneratedType(string typeName)
		{
			Assume.That(this.generatedTypes.ContainsKey(typeName));
			const string suffix = "_AsModreqOnReturnType";
			Assume.That(typeName.EndsWith(suffix));
			var typeNameWithoutSuffix = typeName.Substring(0, typeName.Length - suffix.Length);
			Assume.That(CustomModifiersTestCase.customModifiers.ContainsKey(typeNameWithoutSuffix));
			var modreqs = this.generatedTypes[typeName].GetMethod("Foo").ReturnParameter.GetRequiredCustomModifiers();
			Assume.That(modreqs.Length > 0); 
			CollectionAssert.AreEqual(expected: CustomModifiersTestCase.customModifiers[typeNameWithoutSuffix].Reverse(), actual: modreqs);
		}
[ TestCaseSource ( nameof ( AsModreqOnReturnTypeNames ) ) ] public void ReflectionReturnsCorrectModreqOnReturnTypeForGeneratedType ( 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 modreqs = this . generatedTypes [ typeName ] . GetMethod ( " " ) . ReturnParameter . GetRequiredCustomModifiers ( ) ; Assume . That ( modreqs . Length > 0 ) ; CollectionAssert . AreEqual ( expected : CustomModifiersTestCase . customModifiers [ typeNameWithoutSuffix ] . Reverse ( ) , actual : modreqs ) ; }
This test checks whether reflection correctly reports back the modopts on
the return type in the generated types.
This test checks whether reflection correctly reports back the modopts on the return 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 // ^ see comment about `.Reverse()` above.
typeName
string