public static IEnumerable <object[]> CodeSnippetsToCompile() { // Not LibraryImportAttribute yield return(new object[] { CodeSnippets.UserDefinedPrefixedAttributes, 0, 3 }); // No explicit marshalling for char or string yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <char>(), 5, 0 }); yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <string>(), 5, 0 }); yield return(new object[] { CodeSnippets.MarshalAsArrayParametersAndModifiers <char>(), 5, 0 }); yield return(new object[] { CodeSnippets.MarshalAsArrayParametersAndModifiers <string>(), 5, 0 }); // No explicit marshaling for bool yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <bool>(), 5, 0 }); yield return(new object[] { CodeSnippets.MarshalAsArrayParametersAndModifiers <bool>(), 5, 0 }); // Unsupported StringMarshalling configuration yield return(new object[] { CodeSnippets.BasicParametersAndModifiersWithStringMarshalling <char>(StringMarshalling.Utf8), 6, 0 }); yield return(new object[] { CodeSnippets.BasicParametersAndModifiersWithStringMarshalling <char>(StringMarshalling.Custom), 7, 0 }); yield return(new object[] { CodeSnippets.BasicParametersAndModifiersWithStringMarshalling <string>(StringMarshalling.Custom), 7, 0 }); // Unsupported UnmanagedType yield return(new object[] { CodeSnippets.MarshalAsParametersAndModifiers <char>(UnmanagedType.I1), 5, 0 }); yield return(new object[] { CodeSnippets.MarshalAsParametersAndModifiers <char>(UnmanagedType.U1), 5, 0 }); yield return(new object[] { CodeSnippets.MarshalAsParametersAndModifiers <int[]>(UnmanagedType.SafeArray), 10, 0 }); // Unsupported MarshalAsAttribute usage // * UnmanagedType.CustomMarshaler, MarshalTypeRef, MarshalType, MarshalCookie yield return(new object[] { CodeSnippets.MarshalAsCustomMarshalerOnTypes, 16, 0 }); // Unsupported [In, Out] attributes usage // Blittable array yield return(new object[] { CodeSnippets.ByValueParameterWithModifier <int[]>("Out"), 1, 0 }); yield return(new object[] { CodeSnippets.ByValueParameterWithModifier <int[]>("In, Out"), 1, 0 }); // By ref with [In, Out] attributes yield return(new object[] { CodeSnippets.ByValueParameterWithModifier("in int", "In"), 1, 0 }); yield return(new object[] { CodeSnippets.ByValueParameterWithModifier("ref int", "In"), 1, 0 }); yield return(new object[] { CodeSnippets.ByValueParameterWithModifier("ref int", "In, Out"), 1, 0 }); yield return(new object[] { CodeSnippets.ByValueParameterWithModifier("out int", "Out"), 1, 0 }); // By value non-array with [In, Out] attributes yield return(new object[] { CodeSnippets.ByValueParameterWithModifier <byte>("In"), 1, 0 }); yield return(new object[] { CodeSnippets.ByValueParameterWithModifier <byte>("Out"), 1, 0 }); yield return(new object[] { CodeSnippets.ByValueParameterWithModifier <byte>("In, Out"), 1, 0 }); // LCIDConversion yield return(new object[] { CodeSnippets.LCIDConversionAttribute, 1, 0 }); // No size information for array marshalling from unmanaged to managed // * return, out, ref yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <byte[]>(CodeSnippets.DisableRuntimeMarshalling), 3, 0 }); yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <sbyte[]>(CodeSnippets.DisableRuntimeMarshalling), 3, 0 }); yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <short[]>(CodeSnippets.DisableRuntimeMarshalling), 3, 0 }); yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <ushort[]>(CodeSnippets.DisableRuntimeMarshalling), 3, 0 }); yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <char[]>(CodeSnippets.DisableRuntimeMarshalling), 3, 0 }); yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <string[]>(CodeSnippets.DisableRuntimeMarshalling), 5, 0 }); yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <int[]>(CodeSnippets.DisableRuntimeMarshalling), 3, 0 }); yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <uint[]>(CodeSnippets.DisableRuntimeMarshalling), 3, 0 }); yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <long[]>(CodeSnippets.DisableRuntimeMarshalling), 3, 0 }); yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <ulong[]>(CodeSnippets.DisableRuntimeMarshalling), 3, 0 }); yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <float[]>(CodeSnippets.DisableRuntimeMarshalling), 3, 0 }); yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <double[]>(CodeSnippets.DisableRuntimeMarshalling), 3, 0 }); yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <bool[]>(CodeSnippets.DisableRuntimeMarshalling), 5, 0 }); yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <IntPtr[]>(CodeSnippets.DisableRuntimeMarshalling), 3, 0 }); yield return(new object[] { CodeSnippets.BasicParametersAndModifiers <UIntPtr[]>(CodeSnippets.DisableRuntimeMarshalling), 3, 0 }); // Collection with non-integer size param yield return(new object[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam <float>(isByRef: false), 1, 0 }); yield return(new object[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam <double>(isByRef: false), 1, 0 }); yield return(new object[] { CodeSnippets.MarshalAsArrayParameterWithSizeParam <bool>(isByRef: false), 2, 0 }); yield return(new object[] { CodeSnippets.MarshalUsingArrayParameterWithSizeParam <float>(isByRef: false), 1, 0 }); yield return(new object[] { CodeSnippets.MarshalUsingArrayParameterWithSizeParam <double>(isByRef: false), 1, 0 }); yield return(new object[] { CodeSnippets.MarshalUsingArrayParameterWithSizeParam <bool>(isByRef: false), 2, 0 }); // Custom type marshalling with invalid members yield return(new object[] { CodeSnippets.CustomStructMarshallingByRefValueProperty, 3, 0 }); yield return(new object[] { CodeSnippets.CustomStructMarshallingManagedToNativeOnlyOutParameter, 1, 0 }); yield return(new object[] { CodeSnippets.CustomStructMarshallingManagedToNativeOnlyReturnValue, 1, 0 }); yield return(new object[] { CodeSnippets.CustomStructMarshallingNativeToManagedOnlyInParameter, 1, 0 }); yield return(new object[] { CodeSnippets.CustomStructMarshallingStackallocOnlyRefParameter, 1, 0 }); // Abstract SafeHandle type by reference yield return(new object[] { CodeSnippets.BasicParameterWithByRefModifier("ref", "System.Runtime.InteropServices.SafeHandle"), 1, 0 }); // Collection with constant and element size parameter yield return(new object[] { CodeSnippets.MarshalUsingCollectionWithConstantAndElementCount, 2, 0 }); // Collection with null element size parameter name yield return(new object[] { CodeSnippets.MarshalUsingCollectionWithNullElementName, 2, 0 }); // Generic collection marshaller has different arity than collection. yield return(new object[] { CodeSnippets.GenericCollectionMarshallingArityMismatch, 2, 0 }); yield return(new object[] { CodeSnippets.MarshalAsAndMarshalUsingOnReturnValue, 2, 0 }); yield return(new object[] { CodeSnippets.GenericCollectionWithCustomElementMarshallingDuplicateElementIndirectionLevel, 2, 0 }); yield return(new object[] { CodeSnippets.GenericCollectionWithCustomElementMarshallingUnusedElementIndirectionLevel, 1, 0 }); yield return(new object[] { CodeSnippets.RecursiveCountElementNameOnReturnValue, 2, 0 }); yield return(new object[] { CodeSnippets.RecursiveCountElementNameOnParameter, 2, 0 }); yield return(new object[] { CodeSnippets.MutuallyRecursiveCountElementNameOnParameter, 4, 0 }); yield return(new object[] { CodeSnippets.MutuallyRecursiveSizeParamIndexOnParameter, 4, 0 }); // Ref returns yield return(new object[] { CodeSnippets.RefReturn("int"), 2, 2 }); }