diff --git a/tests/cecil-tests/ApiTest.KnownFailures.cs b/tests/cecil-tests/ApiTest.KnownFailures.cs new file mode 100644 index 0000000000..dece34e032 --- /dev/null +++ b/tests/cecil-tests/ApiTest.KnownFailures.cs @@ -0,0 +1,312 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; + +using NUnit.Framework; + +using Mono.Cecil; +using Mono.Cecil.Cil; + +using Xamarin.Tests; +using Xamarin.Utils; + +#nullable enable + +namespace Cecil.Tests { + + public partial class ApiTest { + static HashSet knownFailuresMustStartWithCapitalizationLetter = new HashSet { + "The field 'Accelerate.vImageGamma Accelerate.vImageGamma::k11ove_5_HalfPrecision' has incorrect capitalization: first letter is not upper case.", + "The field 'Accelerate.vImageGamma Accelerate.vImageGamma::k11over9_HalfPrecision' has incorrect capitalization: first letter is not upper case.", + "The field 'Accelerate.vImageGamma Accelerate.vImageGamma::k5over11_HalfPrecision' has incorrect capitalization: first letter is not upper case.", + "The field 'Accelerate.vImageGamma Accelerate.vImageGamma::k5over9_HalfPrecision' has incorrect capitalization: first letter is not upper case.", + "The field 'Accelerate.vImageGamma Accelerate.vImageGamma::k9over11_HalfPrecision' has incorrect capitalization: first letter is not upper case.", + "The field 'Accelerate.vImageGamma Accelerate.vImageGamma::k9over5_HalfPrecision' has incorrect capitalization: first letter is not upper case.", + "The field 'Accelerate.vImageGamma Accelerate.vImageGamma::kBT709_ForwardHalfPrecision' has incorrect capitalization: first letter is not upper case.", + "The field 'Accelerate.vImageGamma Accelerate.vImageGamma::kBT709_ReverseHalfPrecision' has incorrect capitalization: first letter is not upper case.", + "The field 'Accelerate.vImageGamma Accelerate.vImageGamma::ksRGB_ForwardHalfPrecision' has incorrect capitalization: first letter is not upper case.", + "The field 'Accelerate.vImageGamma Accelerate.vImageGamma::ksRGB_ReverseHalfPrecision' has incorrect capitalization: first letter is not upper case.", + "The field 'Accelerate.vImageGamma Accelerate.vImageGamma::kUseGammaValue' has incorrect capitalization: first letter is not upper case.", + "The field 'Accelerate.vImageGamma Accelerate.vImageGamma::kUseGammaValueHalfPrecision' has incorrect capitalization: first letter is not upper case.", + "The field 'Accelerate.vImageMDTableUsageHint Accelerate.vImageMDTableUsageHint::k16Q12' has incorrect capitalization: first letter is not upper case.", + "The field 'Accelerate.vImageMDTableUsageHint Accelerate.vImageMDTableUsageHint::kFloat' has incorrect capitalization: first letter is not upper case.", + "The field 'AppKit.NSTextScalingType AppKit.NSTextScalingType::iOS' has incorrect capitalization: first letter is not upper case.", + "The field 'AudioToolbox.AudioFormatType AudioToolbox.AudioFormatType::iLBC' has incorrect capitalization: first letter is not upper case.", + "The field 'AudioToolbox.MusicSequenceFileTypeID AudioToolbox.MusicSequenceFileTypeID::iMelody' has incorrect capitalization: first letter is not upper case.", + "The field 'AudioUnit.AudioTypePanner AudioUnit.AudioTypePanner::rHRTF' has incorrect capitalization: first letter is not upper case.", + "The field 'CoreImage.CIFormat CoreImage.CIFormat::kBGRA8' has incorrect capitalization: first letter is not upper case.", + "The field 'CoreImage.CIFormat CoreImage.CIFormat::kRGBA8' has incorrect capitalization: first letter is not upper case.", + "The field 'CoreImage.CIFormat CoreImage.CIFormat::kRGBAf' has incorrect capitalization: first letter is not upper case.", + "The field 'Intents.INCarAudioSource Intents.INCarAudioSource::iPod' has incorrect capitalization: first letter is not upper case.", + "The field 'Intents.INPersonHandleLabel Intents.INPersonHandleLabel::iPhone' has incorrect capitalization: first letter is not upper case.", + "The field 'iTunesLibrary.ITLibDistinguishedPlaylistKind iTunesLibrary.ITLibDistinguishedPlaylistKind::iTunesU' has incorrect capitalization: first letter is not upper case.", + "The field 'iTunesLibrary.ITLibMediaItemMediaKind iTunesLibrary.ITLibMediaItemMediaKind::iOSApplication' has incorrect capitalization: first letter is not upper case.", + "The field 'iTunesLibrary.ITLibMediaItemMediaKind iTunesLibrary.ITLibMediaItemMediaKind::iTunesU' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLLanguageVersion Metal.MTLLanguageVersion::v1_0' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLLanguageVersion Metal.MTLLanguageVersion::v1_1' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLLanguageVersion Metal.MTLLanguageVersion::v1_2' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLLanguageVersion Metal.MTLLanguageVersion::v2_0' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLLanguageVersion Metal.MTLLanguageVersion::v2_1' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLLanguageVersion Metal.MTLLanguageVersion::v2_2' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLLanguageVersion Metal.MTLLanguageVersion::v2_3' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLLanguageVersion Metal.MTLLanguageVersion::v2_4' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLTextureType Metal.MTLTextureType::k1D' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLTextureType Metal.MTLTextureType::k1DArray' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLTextureType Metal.MTLTextureType::k2D' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLTextureType Metal.MTLTextureType::k2DArray' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLTextureType Metal.MTLTextureType::k2DMultisample' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLTextureType Metal.MTLTextureType::k2DMultisampleArray' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLTextureType Metal.MTLTextureType::k3D' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLTextureType Metal.MTLTextureType::kCube' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLTextureType Metal.MTLTextureType::kCubeArray' has incorrect capitalization: first letter is not upper case.", + "The field 'Metal.MTLTextureType Metal.MTLTextureType::kTextureBuffer' has incorrect capitalization: first letter is not upper case.", + "The field 'ObjCRuntime.LinkTarget ObjCRuntime.LinkTarget::i386' has incorrect capitalization: first letter is not upper case.", + "The field 'ObjCRuntime.LinkTarget ObjCRuntime.LinkTarget::x86_64' has incorrect capitalization: first letter is not upper case.", + "The field 'Photos.PHAssetSourceType Photos.PHAssetSourceType::iTunesSynced' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Byte[] AudioToolbox.MidiData::data' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double Accelerate.vImageAffineTransformDouble::a' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double Accelerate.vImageAffineTransformDouble::b' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double Accelerate.vImageAffineTransformDouble::c' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double Accelerate.vImageAffineTransformDouble::d' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double Accelerate.vImageAffineTransformDouble::tx' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double Accelerate.vImageAffineTransformDouble::ty' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double CoreMotion.CMQuaternion::w' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double CoreMotion.CMQuaternion::x' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double CoreMotion.CMQuaternion::y' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double CoreMotion.CMQuaternion::z' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double CoreMotion.CMRotationMatrix::m11' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double CoreMotion.CMRotationMatrix::m12' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double CoreMotion.CMRotationMatrix::m13' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double CoreMotion.CMRotationMatrix::m21' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double CoreMotion.CMRotationMatrix::m22' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double CoreMotion.CMRotationMatrix::m23' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double CoreMotion.CMRotationMatrix::m31' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double CoreMotion.CMRotationMatrix::m32' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double CoreMotion.CMRotationMatrix::m33' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double CoreMotion.CMRotationRate::x' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double CoreMotion.CMRotationRate::y' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Double CoreMotion.CMRotationRate::z' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Int16 Foundation.NSDecimal::m1' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Int16 Foundation.NSDecimal::m2' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Int16 Foundation.NSDecimal::m3' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Int16 Foundation.NSDecimal::m4' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Int16 Foundation.NSDecimal::m5' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Int16 Foundation.NSDecimal::m6' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Int16 Foundation.NSDecimal::m7' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Int16 Foundation.NSDecimal::m8' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Int32 AudioToolbox.MidiData::len' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Int32 AudioToolbox.MidiData::start' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Int32 Foundation.NSDecimal::fields' has incorrect capitalization: first letter is not upper case.", + "The field 'System.IntPtr AudioToolbox.AudioQueue::handle' has incorrect capitalization: first letter is not upper case.", + "The field 'System.IntPtr AudioToolbox.AudioQueueTimeline::queueHandle' has incorrect capitalization: first letter is not upper case.", + "The field 'System.IntPtr AudioToolbox.AudioQueueTimeline::timelineHandle' has incorrect capitalization: first letter is not upper case.", + "The field 'System.IntPtr AudioToolbox.MidiData::buffer' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Runtime.InteropServices.GCHandle AudioToolbox.AudioQueue::gch' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Runtime.InteropServices.NFloat CoreGraphics.CGVector::dx' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Runtime.InteropServices.NFloat CoreGraphics.CGVector::dy' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Single Accelerate.vImageAffineTransformFloat::a' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Single Accelerate.vImageAffineTransformFloat::b' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Single Accelerate.vImageAffineTransformFloat::c' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Single Accelerate.vImageAffineTransformFloat::d' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Single Accelerate.vImageAffineTransformFloat::tx' has incorrect capitalization: first letter is not upper case.", + "The field 'System.Single Accelerate.vImageAffineTransformFloat::ty' has incorrect capitalization: first letter is not upper case.", + "The field 'System.String ObjCRuntime.Constants::iTunesLibraryLibrary' has incorrect capitalization: first letter is not upper case.", + "The field 'System.String ObjCRuntime.Constants::libcLibrary' has incorrect capitalization: first letter is not upper case.", + "The field 'System.String ObjCRuntime.Constants::libcompressionLibrary' has incorrect capitalization: first letter is not upper case.", + "The field 'System.String ObjCRuntime.Constants::libdispatchLibrary' has incorrect capitalization: first letter is not upper case.", + "The field 'System.String ObjCRuntime.Constants::libSystemLibrary' has incorrect capitalization: first letter is not upper case.", + "The field 'UIKit.NSTextScalingType UIKit.NSTextScalingType::iOS' has incorrect capitalization: first letter is not upper case.", + "The method 'System.Int32 ObjCRuntime.Dlfcn::dlclose(System.IntPtr)' has incorrect capitalization: first letter is not upper case.", + "The method 'System.IntPtr AuthenticationServices.ASAuthorizationProviderExtensionLoginManager::_CopyKey(AuthenticationServices.ASAuthorizationProviderExtensionKeyType)' has incorrect capitalization: first letter is not upper case.", + "The method 'System.IntPtr ObjCRuntime.Dlfcn::dlopen(System.String,ObjCRuntime.Dlfcn/Mode)' has incorrect capitalization: first letter is not upper case.", + "The method 'System.IntPtr ObjCRuntime.Dlfcn::dlopen(System.String,System.Int32)' has incorrect capitalization: first letter is not upper case.", + "The method 'System.IntPtr ObjCRuntime.Dlfcn::dlsym(ObjCRuntime.Dlfcn/RTLD,System.String)' has incorrect capitalization: first letter is not upper case.", + "The method 'System.IntPtr ObjCRuntime.Dlfcn::dlsym(System.IntPtr,System.String)' has incorrect capitalization: first letter is not upper case.", + "The method 'System.String ObjCRuntime.Dlfcn::dlerror()' has incorrect capitalization: first letter is not upper case.", + "The method 'System.Void AuthenticationServices.ASAuthorizationProviderExtensionLoginManager::_Save(System.IntPtr,AuthenticationServices.ASAuthorizationProviderExtensionKeyType)' has incorrect capitalization: first letter is not upper case.", + "The parameter '__object' in the method 'System.IAsyncResult Foundation.RegisterObjectRepresentationCompletionHandler::BeginInvoke(Foundation.INSItemProviderWriting,Foundation.NSError,System.AsyncCallback,System.Object)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'A' in the method 'System.Void MetalPerformanceShaders.MPSCnnConvolutionDescriptor::SetNeuronToPReLU(Foundation.NSData)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'Behavior' in the method 'Foundation.NSDecimalNumber Foundation.NSDecimalNumber::Add(Foundation.NSDecimalNumber,Foundation.NSObject)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'Behavior' in the method 'Foundation.NSDecimalNumber Foundation.NSDecimalNumber::Divide(Foundation.NSDecimalNumber,Foundation.NSObject)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'Behavior' in the method 'Foundation.NSDecimalNumber Foundation.NSDecimalNumber::Multiply(Foundation.NSDecimalNumber,Foundation.NSObject)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'Behavior' in the method 'Foundation.NSDecimalNumber Foundation.NSDecimalNumber::MultiplyPowerOf10(System.Int16,Foundation.NSObject)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'Behavior' in the method 'Foundation.NSDecimalNumber Foundation.NSDecimalNumber::RaiseTo(System.UIntPtr,Foundation.NSObject)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'Behavior' in the method 'Foundation.NSDecimalNumber Foundation.NSDecimalNumber::Subtract(Foundation.NSDecimalNumber,Foundation.NSObject)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'Data' in the method 'System.Void AudioToolbox.MidiData::SetData(System.Byte[])' has incorrect capitalization: first letter is not lower case.", + "The parameter 'Data' in the method 'System.Void AudioToolbox.MidiData::SetData(System.Int32,System.Int32,System.Byte[])' has incorrect capitalization: first letter is not lower case.", + "The parameter 'IntPtrOffsets' in the method 'System.Void Metal.IMTLRenderCommandEncoder::SetFragmentBuffers(Metal.IMTLBuffer,System.IntPtr,Foundation.NSRange)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'ISO' in the method 'AVFoundation.AVCaptureManualExposureBracketedStillImageSettings AVFoundation.AVCaptureManualExposureBracketedStillImageSettings::Create(CoreMedia.CMTime,System.Single)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'ISO' in the method 'System.Threading.Tasks.Task`1 AVFoundation.AVCaptureDevice::LockExposureAsync(CoreMedia.CMTime,System.Single)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'ISO' in the method 'System.Void AVFoundation.AVCaptureDevice::LockExposure(CoreMedia.CMTime,System.Single,System.Action`1)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'ItemLoadingHandler' in the method 'System.Void QuickLookUI.QLPreviewingController_Extensions::PreparePreviewOfSearchableItem(QuickLookUI.IQLPreviewingController,System.String,System.String,System.Action`1)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'JPEGSampleBuffer' in the method 'Foundation.NSData AVFoundation.AVCapturePhotoOutput::GetJpegPhotoDataRepresentation(CoreMedia.CMSampleBuffer,CoreMedia.CMSampleBuffer)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'MimeType' in the method 'System.Boolean WebKit.WebView::CanShowMimeType(System.String)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'OfSize' in the method 'System.Threading.Tasks.Task`1 UIKit.UIImage::PrepareThumbnailAsync(CoreGraphics.CGSize)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'OfSize' in the method 'System.Void UIKit.UIImage::PrepareThumbnail(CoreGraphics.CGSize,System.Action`1)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'OSstatus' in the method 'AudioToolbox.MusicPlayer AudioToolbox.MusicPlayer::Create(AudioToolbox.MusicPlayerStatus&)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'RSSI' in the method 'System.Void CoreBluetooth.CBCentralManagerDelegate_Extensions::DiscoveredPeripheral(CoreBluetooth.ICBCentralManagerDelegate,CoreBluetooth.CBCentralManager,CoreBluetooth.CBPeripheral,Foundation.NSDictionary,Foundation.NSNumber)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'RSSI' in the method 'System.Void CoreBluetooth.CBCentralManagerDelegate::DiscoveredPeripheral(CoreBluetooth.CBCentralManager,CoreBluetooth.CBPeripheral,Foundation.NSDictionary,Foundation.NSNumber)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'RSSI' in the method 'System.Void CoreBluetooth.CBDiscoveredPeripheralEventArgs::.ctor(CoreBluetooth.CBPeripheral,Foundation.NSDictionary,Foundation.NSNumber)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'TeamIdentifier' in the method 'System.Void AutomaticAssessmentConfiguration.AEAssessmentApplication::.ctor(System.String,System.String)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'TLSParameters' in the method 'NetworkExtension.NWTcpConnection NetworkExtension.NEProvider::CreateTcpConnectionToEndpoint(NetworkExtension.NWEndpoint,System.Boolean,NetworkExtension.NWTlsParameters,Foundation.NSObject)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URL' in the method 'AVFoundation.AVMovie AVFoundation.AVMovie::FromUrl(Foundation.NSUrl,Foundation.NSDictionary`2)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URL' in the method 'AVFoundation.AVMutableMovie AVFoundation.AVMutableMovie::FromUrl(Foundation.NSUrl,Foundation.NSDictionary`2,Foundation.NSError&)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URL' in the method 'AVFoundation.AVPlayer AVFoundation.AVPlayer::FromUrl(Foundation.NSUrl)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URL' in the method 'AVFoundation.AVPlayerItem AVFoundation.AVPlayerItem::FromUrl(Foundation.NSUrl)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'Url' in the method 'CoreData.NSPersistentStoreDescription CoreData.NSPersistentStoreDescription::GetPersistentStoreDescription(Foundation.NSUrl)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URL' in the method 'System.Boolean AVFoundation.AVMovie_AVMovieMovieHeaderSupport::WriteMovieHeader(AVFoundation.AVMovie,Foundation.NSUrl,System.String,AVFoundation.AVMovieWritingOptions,Foundation.NSError&)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URL' in the method 'System.Boolean Social.SLComposeServiceViewController::ShouldInteractWithUrl(UIKit.UITextView,Foundation.NSUrl,Foundation.NSRange)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URL' in the method 'System.Boolean UIKit.UITextViewDelegate_Extensions::ShouldInteractWithUrl(UIKit.IUITextViewDelegate,UIKit.UITextView,Foundation.NSUrl,Foundation.NSRange)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URL' in the method 'System.Boolean UIKit.UITextViewDelegate::ShouldInteractWithUrl(UIKit.UITextView,Foundation.NSUrl,Foundation.NSRange)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URL' in the method 'System.Threading.Tasks.Task`1 HealthKit.HKAttachmentStore::AddAttachmentAsync(HealthKit.HKObject,System.String,UniformTypeIdentifiers.UTType,Foundation.NSUrl,Foundation.NSDictionary`2)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URL' in the method 'System.Void AVFoundation.AVCompositionTrackSegment::.ctor(Foundation.NSUrl,System.Int32,CoreMedia.CMTimeRange,CoreMedia.CMTimeRange)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URL' in the method 'System.Void AVFoundation.AVFragmentedMovie::.ctor(Foundation.NSUrl,Foundation.NSDictionary`2)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URL' in the method 'System.Void AVFoundation.AVMediaDataStorage::.ctor(Foundation.NSUrl,Foundation.NSDictionary`2)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URL' in the method 'System.Void AVFoundation.AVMovie::.ctor(Foundation.NSUrl,Foundation.NSDictionary`2)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URL' in the method 'System.Void AVFoundation.AVMutableMovie::.ctor(Foundation.NSUrl,Foundation.NSDictionary`2,Foundation.NSError&)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URL' in the method 'System.Void AVFoundation.AVPlayer::.ctor(Foundation.NSUrl)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URL' in the method 'System.Void AVFoundation.AVPlayerItem::.ctor(Foundation.NSUrl)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URL' in the method 'System.Void HealthKit.HKAttachmentStore::AddAttachment(HealthKit.HKObject,System.String,UniformTypeIdentifiers.UTType,Foundation.NSUrl,Foundation.NSDictionary`2,System.Action`2)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URLAsset' in the method 'AVFoundation.AVAggregateAssetDownloadTask AVFoundation.AVAssetDownloadUrlSession::GetAssetDownloadTask(AVFoundation.AVUrlAsset,AVFoundation.AVMediaSelection[],System.String,Foundation.NSData,Foundation.NSDictionary`2)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'URLTemplate' in the method 'System.Void MapKit.MKTileOverlay::.ctor(System.String)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'Window' in the method 'System.Threading.Tasks.Task`1 AppKit.NSAlert::BeginSheetAsync(AppKit.NSWindow)' has incorrect capitalization: first letter is not lower case.", + "The parameter 'Window' in the method 'System.Void AppKit.NSAlert::BeginSheet(AppKit.NSWindow,System.Action`1)' has incorrect capitalization: first letter is not lower case.", + "The property 'Foundation.NSString AddressBook.ABPersonPhoneLabel::iPhone()' has incorrect capitalization: first letter is not upper case.", + "The property 'Foundation.NSString AVFoundation.AVMetadataIdentifiers/QuickTimeMetadata::iXML()' has incorrect capitalization: first letter is not upper case.", + "The property 'Foundation.NSString Contacts.CNLabelPhoneNumberKey::iPhone()' has incorrect capitalization: first letter is not upper case.", + "The property 'Foundation.NSString MobileCoreServices.UTType::k3dObject()' has incorrect capitalization: first letter is not upper case.", + "The property 'MediaPlayer.MPMusicPlayerController MediaPlayer.MPMusicPlayerController::iPodMusicPlayer()' has incorrect capitalization: first letter is not upper case.", + "The type 'Accelerate.vImage' has incorrect capitalization: first letter is not upper case.", + "The type 'Accelerate.vImageAffineTransformDouble' has incorrect capitalization: first letter is not upper case.", + "The type 'Accelerate.vImageAffineTransformFloat' has incorrect capitalization: first letter is not upper case.", + "The type 'Accelerate.vImageBuffer' has incorrect capitalization: first letter is not upper case.", + "The type 'Accelerate.vImageError' has incorrect capitalization: first letter is not upper case.", + "The type 'Accelerate.vImageFlags' has incorrect capitalization: first letter is not upper case.", + "The type 'Accelerate.vImageGamma' has incorrect capitalization: first letter is not upper case.", + "The type 'Accelerate.vImageInterpolationMethod' has incorrect capitalization: first letter is not upper case.", + "The type 'Accelerate.vImageMDTableUsageHint' has incorrect capitalization: first letter is not upper case.", + "The type 'AVFoundation.AVMetadataIdentifiers/iTunesMetadata' has incorrect capitalization: first letter is not upper case.", + "The type 'SceneKit._SCNShaderModifiers' has incorrect capitalization: first letter is not upper case.", + }; + + static HashSet knownFailuresInvalidStrings = new HashSet { + "The field 'AVFoundation.AVError AVFoundation.AVError::InvalidOutputURLPathExtension' has an invalid term 'URL'. Replace with: 'Url'.", + "The field 'CoreFoundation.CFNetworkErrors CoreFoundation.CFNetworkErrors::BadURL' has an invalid term 'URL'. Replace with: 'Url'.", + "The field 'CoreFoundation.CFNetworkErrors CoreFoundation.CFNetworkErrors::HttpBadURL' has an invalid term 'URL'. Replace with: 'Url'.", + "The field 'CoreFoundation.CFNetworkErrors CoreFoundation.CFNetworkErrors::UnsupportedURL' has an invalid term 'URL'. Replace with: 'Url'.", + "The field 'Foundation.NSUrlError Foundation.NSUrlError::BadURL' has an invalid term 'URL'. Replace with: 'Url'.", + "The field 'Foundation.NSUrlError Foundation.NSUrlError::UnsupportedURL' has an invalid term 'URL'. Replace with: 'Url'.", + "The field 'GLKit.GLKTextureLoaderError GLKit.GLKTextureLoaderError::FileOrURLNotFound' has an invalid term 'URL'. Replace with: 'Url'.", + "The field 'SharedWithYou.SWHighlightCenterErrorCode SharedWithYou.SWHighlightCenterErrorCode::InvalidURL' has an invalid term 'URL'. Replace with: 'Url'.", + "The field 'ShazamKit.SHErrorCode ShazamKit.SHErrorCode::CustomCatalogInvalidURL' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'CoreFoundation.CFProxy[] CoreFoundation.CFNetwork::GetProxiesForURL(Foundation.NSUrl,CoreFoundation.CFProxySettings)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSAppleEventDescriptor Foundation.NSAppleEventDescriptor::FromApplicationURL(Foundation.NSUrl)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSAppleEventDescriptor Foundation.NSAppleEventDescriptor::FromFileURL(Foundation.NSUrl)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSArray UIKit.UIPasteboard::get_TypeListURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString AppKit.NSAccessibilityAttributes::get_URLAttribute()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString AppKit.NSSpellChecker::get_TextCheckingDocumentURLKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString AVFoundation.AVMetadata::get_ID3MetadataKeyUserURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString AVFoundation.AVMetadata::get_QuickTimeUserDataKeyURLLink()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString Foundation.NSMetadataQuery::get_ItemURLKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString Foundation.NSMetadataQuery::get_UbiquitousItemURLInLocalContainerKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString Foundation.NSProgress::get_FileURLKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString Foundation.NSUrl::get_ParentDirectoryURLKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString Foundation.NSUrl::get_VolumeURLForRemountingKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString Foundation.NSUrl::get_VolumeURLKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString ImageIO.CGImageProperties::get_IPTCContactInfoWebURLs()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString ImageKit.IKImageBrowserItem::get_NSURLRepresentationType()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString MediaPlayer.MPMediaItem::get_AssetURLProperty()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString MessageUI.MFMessageComposeViewController::get_AttachmentURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString MobileCoreServices.UTType::get_FileURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString MobileCoreServices.UTType::get_ReferenceURLKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString MobileCoreServices.UTType::get_URL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString MobileCoreServices.UTType::get_URLBookmarkData()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString QuartzComposer.QCComposition::get_InputRSSFeedURLKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString QuartzComposer.QCComposition::get_OutputWebPageURLKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSString UIKit.UIImagePickerController::get_MediaURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrl AVFoundation.AVAssetWriter::get_OutputURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrl AVFoundation.AVCaptureFileOutput::get_OutputFileURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrl AVFoundation.AVMediaDataStorage::get_URL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrl AVFoundation.AVMovie::get_URL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrl AVFoundation.AVMutableMovieTrack::get_SampleReferenceBaseURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrl FinderSync.FIFinderSyncController::get_TargetedURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrl Foundation.NSAppleEventDescriptor::get_FileURLValue()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrl Foundation.NSFileWrapper::get_SymbolicLinkDestinationURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrl Foundation.NSMutableUrlRequest::get_MainDocumentURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrl Foundation.NSUrlRequest::get_MainDocumentURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrl Foundation.NSUserDefaults::URLForKey(System.String)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrl MapKit.MKTileOverlay::URLForTilePath(MapKit.MKTileOverlayPath)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrl MediaPlayer.MPMediaItem::get_AssetURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrl WebKit.DomHtmlInputElement::get_AbsoluteImageURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrl WebKit.WebDataSource::get_UnreachableURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrl[] FinderSync.FIFinderSyncController::get_SelectedItemURLs()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrlCache Foundation.NSUrlSessionConfiguration::get_URLCache()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'Foundation.NSUrlCredentialStorage Foundation.NSUrlSessionConfiguration::get_URLCredentialStorage()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Boolean AppKit.NSMutableAttributedStringAppKitAddons::ReadFromURL(Foundation.NSMutableAttributedString,Foundation.NSUrl,Foundation.NSAttributedStringDocumentAttributes,Foundation.NSDictionary&,Foundation.NSError&)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Boolean AppKit.NSMutableAttributedStringAppKitAddons::ReadFromURL(Foundation.NSMutableAttributedString,Foundation.NSUrl,Foundation.NSAttributedStringDocumentAttributes,Foundation.NSDictionary&)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Boolean AppKit.NSMutableAttributedStringAppKitAddons::ReadFromURL(Foundation.NSMutableAttributedString,Foundation.NSUrl,Foundation.NSDictionary,Foundation.NSDictionary&,Foundation.NSError&)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Boolean AppKit.NSMutableAttributedStringAppKitAddons::ReadFromURL(Foundation.NSMutableAttributedString,Foundation.NSUrl,Foundation.NSDictionary,Foundation.NSDictionary&)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Boolean AppKit.NSSpeechSynthesizer::StartSpeakingStringtoURL(System.String,Foundation.NSUrl)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Boolean CarPlay.CPApplicationDelegate::HandleOpenURL(UIKit.UIApplication,Foundation.NSUrl)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Boolean Foundation.NSFileWrapper::MatchesContentsOfURL(Foundation.NSUrl)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Boolean UIKit.UIApplicationDelegate_Extensions::HandleOpenURL(UIKit.IUIApplicationDelegate,UIKit.UIApplication,Foundation.NSUrl)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Boolean UIKit.UIApplicationDelegate::HandleOpenURL(UIKit.UIApplication,Foundation.NSUrl)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.String CoreFoundation.CFProxySettings::get_ProxyAutoConfigURLString()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.String MapKit.MKTileOverlay::get_URLTemplate()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Uri CFNetwork.CFHTTPStream::get_FinalURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Void AppKit.NSDocumentController::NoteNewRecentDocumentURL(Foundation.NSUrl)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Void AVFoundation.AVMutableMovieTrack::set_SampleReferenceBaseURL(Foundation.NSUrl)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Void Foundation.NSMutableUrlRequest::set_MainDocumentURL(Foundation.NSUrl)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Void Foundation.NSUrlSessionConfiguration::set_URLCache(Foundation.NSUrlCache)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Void Foundation.NSUrlSessionConfiguration::set_URLCredentialStorage(Foundation.NSUrlCredentialStorage)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Void Foundation.NSUserDefaults::SetURL(Foundation.NSUrl,System.String)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Void ImageKit.IKImageView::SetImageWithURL(Foundation.NSUrl)' has an invalid term 'URL'. Replace with: 'Url'.", + "The method 'System.Void UIKit.UIGraphics::SetPDFContextURL(Foundation.NSUrl,CoreGraphics.CGRect)' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSArray UIKit.UIPasteboard::TypeListURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString AppKit.NSAccessibilityAttributes::URLAttribute()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString AppKit.NSSpellChecker::TextCheckingDocumentURLKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString AVFoundation.AVMetadata::ID3MetadataKeyUserURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString AVFoundation.AVMetadata::QuickTimeUserDataKeyURLLink()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString Foundation.NSMetadataQuery::ItemURLKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString Foundation.NSMetadataQuery::UbiquitousItemURLInLocalContainerKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString Foundation.NSProgress::FileURLKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString Foundation.NSUrl::ParentDirectoryURLKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString Foundation.NSUrl::VolumeURLForRemountingKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString Foundation.NSUrl::VolumeURLKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString ImageIO.CGImageProperties::IPTCContactInfoWebURLs()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString ImageKit.IKImageBrowserItem::NSURLRepresentationType()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString MediaPlayer.MPMediaItem::AssetURLProperty()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString MessageUI.MFMessageComposeViewController::AttachmentURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString MobileCoreServices.UTType::FileURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString MobileCoreServices.UTType::ReferenceURLKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString MobileCoreServices.UTType::URL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString MobileCoreServices.UTType::URLBookmarkData()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString QuartzComposer.QCComposition::InputRSSFeedURLKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString QuartzComposer.QCComposition::OutputWebPageURLKey()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSString UIKit.UIImagePickerController::MediaURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSUrl AVFoundation.AVAssetWriter::OutputURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSUrl AVFoundation.AVCaptureFileOutput::OutputFileURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSUrl AVFoundation.AVMediaDataStorage::URL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSUrl AVFoundation.AVMovie::URL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSUrl AVFoundation.AVMutableMovieTrack::SampleReferenceBaseURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSUrl FinderSync.FIFinderSyncController::TargetedURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSUrl Foundation.NSAppleEventDescriptor::FileURLValue()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSUrl Foundation.NSFileWrapper::SymbolicLinkDestinationURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSUrl Foundation.NSMutableUrlRequest::MainDocumentURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSUrl Foundation.NSUrlRequest::MainDocumentURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSUrl MediaPlayer.MPMediaItem::AssetURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSUrl WebKit.DomHtmlInputElement::AbsoluteImageURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSUrl WebKit.WebDataSource::UnreachableURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSUrl[] FinderSync.FIFinderSyncController::SelectedItemURLs()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSUrlCache Foundation.NSUrlSessionConfiguration::URLCache()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'Foundation.NSUrlCredentialStorage Foundation.NSUrlSessionConfiguration::URLCredentialStorage()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'System.String CoreFoundation.CFProxySettings::ProxyAutoConfigURLString()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'System.String MapKit.MKTileOverlay::URLTemplate()' has an invalid term 'URL'. Replace with: 'Url'.", + "The property 'System.Uri CFNetwork.CFHTTPStream::FinalURL()' has an invalid term 'URL'. Replace with: 'Url'.", + "The type 'Foundation.NSURLRequestAttribution' has an invalid term 'URL'. Replace with: 'Url'.", + "The type 'NetworkExtension.NSMutableURLRequest_NEHotspotHelper' has an invalid term 'URL'. Replace with: 'Url'.", + }; + } +} diff --git a/tests/cecil-tests/ApiTest.cs b/tests/cecil-tests/ApiTest.cs index 3403fb73b7..828d47399b 100644 --- a/tests/cecil-tests/ApiTest.cs +++ b/tests/cecil-tests/ApiTest.cs @@ -17,7 +17,7 @@ using Xamarin.Utils; namespace Cecil.Tests { [TestFixture] - public class ApiTest { + public partial class ApiTest { [TestCaseSource (typeof (Helper), nameof (Helper.PlatformAssemblyDefinitions))] [TestCaseSource (typeof (Helper), nameof (Helper.NetPlatformAssemblyDefinitions))] public void ARConfiguration_GetSupportedVideoFormats (AssemblyInfo info) @@ -49,5 +49,115 @@ namespace Cecil.Tests { failures.Add (failure); Console.WriteLine (failure); } + + // Capitalization rules: + // * All types, methods, properties, fields, events must start with an upper-cased letter. + // * All parameters must start with a lower-cased letter + [Test] + public void MustStartWithCapitalLetter () + { + Configuration.IgnoreIfAnyIgnoredPlatforms (); + + var failures = new Dictionary (); + + foreach (var info in Helper.NetPlatformImplementationAssemblyDefinitions) { + var assembly = info.Assembly; + foreach (var member in assembly.EnumeratePublicMembers ()) { + // Presumably obsolete members have been obsoleted for a reason, so assume there's a correctly capitalized version. + if (((ICustomAttributeProvider) member).IsObsolete ()) + continue; + + if (member is MethodDefinition method) { + // Check parameter names + foreach (var param in method.Parameters) { + if (param.Index == 0 && method.IsExtensionMethod ()) + continue; + if (!char.IsLower (param.Name [0])) { + var msg = $"The parameter '{param.Name}' in the method '{method.FullName}' has incorrect capitalization: first letter is not lower case."; + failures [msg] = new (msg, method.RenderLocation ()); + } + } + + // skip constructors + if (method.IsConstructor) + continue; + // skip property accessors + if (method.IsPropertyAccessor ()) + continue; + // skip event methods + if (method.IsEventMethod ()) + continue; + // skip operators + if (method.IsOperator ()) + continue; + } else if (member is FieldDefinition field) { + if (field.Name == "value__" && !field.IsStatic && field.DeclaringType.IsEnum) + continue; + } + + if (!char.IsUpper (member.Name [0]) && !IsAcceptableCapitalization (member)) { + var msg = $"The {member.GetType ().Name.Replace ("Definition", "").ToLower ()} '{member.FullName}' has incorrect capitalization: first letter is not upper case."; + failures [msg] = new (msg, member.RenderLocation ()); + } + } + } + + Helper.AssertFailures (failures, knownFailuresMustStartWithCapitalizationLetter, nameof (knownFailuresMustStartWithCapitalizationLetter), "Incorrect capitalization", (v) => $"{v.Location}: {v.Message}"); + } + + // The difference between this and the known failures is that these aren't failures (that should be fixed), they're exceptions we've deemed acceptable (and shouldn't be fixed). + bool IsAcceptableCapitalization (MemberReference mr) + { + if (mr is FieldDefinition field) { + switch (field.DeclaringType.FullName) { + case "Metal.MTLFeatureSet": + if (field.Name.StartsWith ("iOS_", StringComparison.Ordinal)) + return true; + if (field.Name.StartsWith ("macOS_", StringComparison.Ordinal)) + return true; + if (field.Name.StartsWith ("tvOS_", StringComparison.Ordinal)) + return true; + break; + case "Metal.MTLGpuFamily": + if (field.Name.StartsWith ("iOSMac", StringComparison.Ordinal)) + return true; + break; + } + } else if (mr is PropertyDefinition property) { + switch (property.DeclaringType.FullName) { + case "AVFoundation.AVMetadata": + if (property.Name.StartsWith ("iTunes", StringComparison.Ordinal)) + return true; + break; + } + } + return false; + } + + [Test] + public void InvalidStrings () + { + Configuration.IgnoreIfAnyIgnoredPlatforms (); + + var invalidStrings = new [] { + new { Find = "URL", Replacement = "Url" } + }; + + var failures = new Dictionary (); + + foreach (var info in Helper.NetPlatformImplementationAssemblyDefinitions) { + var assembly = info.Assembly; + foreach (var member in assembly.EnumeratePublicMembers ()) { + foreach (var term in invalidStrings) { + if (member.Name.Contains (term.Find)) { + var msg = $"The {member.GetType ().Name.Replace ("Definition", "").ToLower ()} '{member.FullName}' has an invalid term '{term.Find}'. Replace with: '{term.Replacement}'."; + failures [msg] = new (msg, member.RenderLocation ()); + } + } + } + } + + Helper.AssertFailures (failures, knownFailuresInvalidStrings, nameof (knownFailuresInvalidStrings), "In the file tests/cecil-tests/ApiTest.cs, read the guide carefully.", (v) => $"{v.Location}: {v.Message}"); + } } } diff --git a/tests/cecil-tests/CecilExtensions.cs b/tests/cecil-tests/CecilExtensions.cs index b47f88fa3a..5cd749bf47 100644 --- a/tests/cecil-tests/CecilExtensions.cs +++ b/tests/cecil-tests/CecilExtensions.cs @@ -194,6 +194,75 @@ namespace Xamarin.Utils { return null; } + + public static bool IsPropertyAccessor (this MethodDefinition? accessor) + { + return FindProperty (accessor) is not null; + } + + public static bool IsEventMethod (this MethodDefinition? method) + { + if (method is null) + return false; + + if (!method.IsSpecialName) + return false; + + if (!method.DeclaringType.HasEvents) + return false; + + foreach (var evt in method.DeclaringType.Events) { + if (evt.InvokeMethod == method) + return true; + if (evt.AddMethod == method) + return true; + if (evt.RemoveMethod == method) + return true; + if (!evt.HasOtherMethods) + continue; + if (evt.OtherMethods.Contains (method)) + return true; + } + + return false; + } + + public static bool IsOperator (this MethodDefinition? method) + { + if (method is null) + return false; + + if (!method.IsSpecialName) + return false; + + if (!method.IsStatic) + return false; + + return method.Name.StartsWith ("op_", StringComparison.Ordinal); + } + + public static bool IsExtensionMethod (this MethodDefinition? method) + { + if (method is null) + return false; + + if (!method.IsStatic) + return false; + + if (!method.HasParameters) + return false; + + if (!method.HasCustomAttributes) + return false; + + foreach (var ca in method.CustomAttributes) { + if (ca.AttributeType.Is ("System.Runtime.CompilerServices", "ExtensionAttribute")) { + return true; + } + } + + return false; + } } } diff --git a/tests/cecil-tests/Helper.cs b/tests/cecil-tests/Helper.cs index 4ee27af9b5..7c89db0f66 100644 --- a/tests/cecil-tests/Helper.cs +++ b/tests/cecil-tests/Helper.cs @@ -40,6 +40,11 @@ namespace Cecil.Tests { return ad; } + public static void AssertFailures (HashSet? currentFailures, HashSet knownFailures, string nameOfKnownFailureSet, string message) + { + AssertFailures (currentFailures?.ToDictionary (v => v) ?? new Dictionary (), knownFailures, nameOfKnownFailureSet, message, (v) => v); + } + public static void AssertFailures (Dictionary currentFailures, HashSet knownFailures, string nameOfKnownFailureSet, string message) { AssertFailures (currentFailures, knownFailures, nameOfKnownFailureSet, message, (v) => v); @@ -219,6 +224,128 @@ namespace Cecil.Tests { yield return item; } + public static IEnumerable EnumerateMembers (this AssemblyDefinition assembly, Func? filter = null) + { + foreach (var item in assembly.EnumerateTypes (filter)) + yield return item; + + foreach (var item in assembly.EnumerateFields (filter)) + yield return item; + + foreach (var item in assembly.EnumerateMethods (filter)) + yield return item; + + foreach (var item in assembly.EnumerateProperties (filter)) + yield return item; + + foreach (var item in assembly.EnumerateEvents (filter)) + yield return item; + } + + public static bool IsPubliclyVisible (this TypeDefinition type) + { + if (type.IsNested) { + if (type.IsNestedAssembly || type.IsNestedFamilyAndAssembly || type.IsNestedPrivate) + return false; + return IsPubliclyVisible (type.DeclaringType); + } + + return type.IsPublic; + } + + public static bool IsPubliclyVisible (this FieldDefinition field) + { + if (!IsPubliclyVisible (field.DeclaringType)) + return false; + + var visibility = field.Attributes & FieldAttributes.FieldAccessMask; + switch (visibility) { + case FieldAttributes.Private: + case FieldAttributes.FamANDAssem: + case FieldAttributes.Assembly: + return false; + case FieldAttributes.Family: + case FieldAttributes.FamORAssem: + case FieldAttributes.Public: + return true; + default: + throw new NotImplementedException ($"Unknown visibility: {visibility}"); + } + } + + public static bool IsPubliclyVisible (this MethodDefinition method) + { + if (!IsPubliclyVisible (method.DeclaringType)) + return false; + + var visibility = method.Attributes & MethodAttributes.MemberAccessMask; + switch (visibility) { + case MethodAttributes.Private: + case MethodAttributes.FamANDAssem: + case MethodAttributes.Assembly: + return false; + case MethodAttributes.Family: + case MethodAttributes.FamORAssem: + case MethodAttributes.Public: + return true; + default: + throw new NotImplementedException ($"Unknown visibility: {visibility}"); + } + } + + public static bool IsPubliclyVisible (this EventDefinition evt) + { + if (!IsPubliclyVisible (evt.DeclaringType)) + return false; + + var invokeMethod = evt.InvokeMethod; + if (invokeMethod is not null && IsPubliclyVisible (invokeMethod)) + return true; + var addMethod = evt.AddMethod; + if (addMethod is not null && IsPubliclyVisible (addMethod)) + return true; + var removeMethod = evt.RemoveMethod; + if (removeMethod is not null && IsPubliclyVisible (removeMethod)) + return true; + return false; + } + + public static bool IsPubliclyVisible (this PropertyDefinition property) + { + if (!IsPubliclyVisible (property.DeclaringType)) + return false; + + var getter = property.GetMethod; + if (getter is not null && IsPubliclyVisible (getter)) + return true; + var setter = property.SetMethod; + if (setter is not null && IsPubliclyVisible (setter)) + return true; + return false; + } + + public static bool IsPubliclyVisible (this MemberReference member) + { + return member switch { + PropertyDefinition pd => IsPubliclyVisible (pd), + EventDefinition ed => IsPubliclyVisible (ed), + MethodDefinition md => IsPubliclyVisible (md), + FieldDefinition fd => IsPubliclyVisible (fd), + TypeDefinition td => IsPubliclyVisible (td), + _ => throw new NotImplementedException (member.GetType ().FullName), + }; + } + + public static IEnumerable EnumeratePublicMembers (this AssemblyDefinition assembly, Func? filter = null) + { + var visibleFilter = (MemberReference mr) => { + if (filter is not null && !filter (mr)) + return false; + return IsPubliclyVisible (mr); + }; + return EnumerateMembers (assembly, visibleFilter); + } + public static IEnumerable EnumerateAttributeProviders (this TypeDefinition type, Func? filter = null) { // EnumerateNestedTypes will recurse, but we don't want to do that here. @@ -419,7 +546,7 @@ namespace Cecil.Tests { return string.Empty; } - public static string RenderLocation (this ICustomAttributeProvider provider) + public static string RenderLocation (this object provider) { if (provider is IMemberDefinition md) return RenderLocation (md);