C#/WinRT에서 WinRT 형식의 .NET 매핑

이 문서에서는 .NET 6 이상을 대상으로 하는 데스크톱 앱에서 C#/WinRT가 WinRT(Windows 런타임) 형식과 .NET 형식 간에 수행하는 매핑을 나열합니다. 이러한 앱에서 Visual Studio IntelliSense는 Windows 런타임 형식 대신 .NET 형식을 표시합니다. 예를 들어 Windows 런타임 메서드가 IVector<string> 형식의 매개 변수를 사용하는 경우 IntelliSense가 IList<string> 형식의 매개 변수를 표시합니다. 마찬가지로, C#/WinRT를 사용하여 작성된 WinRT 구성 요소에서는 멤버 서명에 .NET 형식을 사용합니다. C#/WinRT를 사용하여 Windows 런타임 구성 요소를 생성하는 경우 .NET 형식이 해당 WinRT 형식으로 변환됩니다.

C#/WinRT 사용자 지정 형식 매핑은 Windows SDK 또는 WinUI 3(WinUI 3은 Windows 앱 SDK의 일부임)의 형식별로 분류됩니다. Windows SDK 매핑에 대한 WinRT 형식은 Windows.* 네임스페이스 아래에 있으며 WinUI 3 매핑에 대한 WinRT 형식은 Microsoft.UI.Xaml.* 네임스페이스 아래에 있습니다. C#/WinRT가 WinRT 형식에 대해 만드는 사용자 지정 형식 매핑에는 다음 두 가지 이유가 있습니다.

  • 다른 이름 및/또는 네임스페이스로 .NET 형식에 매핑되는 WinRT 형식. 이러한 사용자 지정 매핑은 WinRT 형식을 기존 .NET 해당 형식에 매핑하기 위한 것입니다. 매핑이 다른 형식(예: 클래스 형식에 매핑되는 값 형식)인 경우도 있습니다.

  • 같은 이름 및 네임스페이스로 .NET 형식에 매핑되는 WinRT 형식. 이러한 사용자 지정 매핑은 일반적으로 성능 또는 향상을 위한 것이며 C#에서 직접 구현됩니다. WinRT 및 .NET에서 네임스페이스 이름과 형식 이름이 동일한 대부분의 형식은 구조(또는 열거 등의 구조와 관련된 형식)입니다. WinRT에서 구조체에는 필드 외에 멤버가 없고 .NET이 숨기는 도우미 형식이 필요합니다. 이러한 구조의 .NET 버전에는 숨겨진 도우미 형식(예: Windows.UI.Color)의 기능을 제공하는 속성 및 메서드가 있습니다.

참고 항목

UWP 앱의 컨텍스트에서 WinRT와 .NET 형식 간의 매핑 목록은 UWP에서 WinRT 형식의 .NET 매핑을 참조하세요.

Windows SDK의 WinRT 형식에 대한 매핑

다른 이름 및/또는 네임스페이스를 가진 형식

WinRT 형식/네임스페이스 .NET 형식/네임스페이스
DateTime (Windows.Foundation) DateTimeOffset (System)
EventHandler<T> (Windows.Foundation) EventHandler<T> (System)
EventRegistrationToken (Windows.Foundation) EventRegistrationToken(WinRT)
HResult (Windows.Foundation) Exception (System)
IClosable (Windows.Foundation) IDisposable (System)
IReference<T> (Windows.Foundation) Nullable<T> (System)
TimeSpan (Windows.Foundation) TimeSpan (System)
Uri (Windows.Foundation) Uri (System)
IIterable<T> (Windows.Foundation.Collections) IEnumerable<T> (System.Collections.Generic)
IIterator<T>(Windows.Foundation.Collections) IEnumerator<T>(System.Collections.Generic)
IMap<K,V> (Windows.Foundation.Collections) IDictionary<TKey,TValue> (System.Collections.Generic)
IMapView<K,V> (Windows.Foundation.Collections) IReadOnlyDictionary<TKey,TValue> (System.Collections.Generic)
IKeyValuePair<K,V> (Windows.Foundation.Collections) KeyValuePair<TKey,TValue> (System.Collections.Generic)
IVector<T> (Windows.Foundation.Collections) IList<T> (System.Collections.Generic)
IVectorView<T> (Windows.Foundation.Collections) IReadOnlyList<T> (System.Collections.Generic)
AttributeTargets (Windows.Foundation.Metadata) AttributeTargets (System)
AttributeUsageAttribute (Windows.Foundation.Metadata) AttributeUsageAttribute (System)
Matrix3x2(Windows.Foundation.Numerics) Matrix3x2(System.Numerics)
Matrix4x4(Windows.Foundation.Numerics) Matrix4x4(System.Numerics)
Plane(Windows.Foundation.Numerics) Plane(System.Numerics)
Quaternion(Windows.Foundation.Numerics) Quaternion(System.Numerics)
Vector2(Windows.Foundation.Numerics) Vector2(System.Numerics)
Vector3(Windows.Foundation.Numerics) Vector3(System.Numerics)
Vector4(Windows.Foundation.Numerics) Vector4(System.Numerics)
IBindableIterable (Windows.UI.Xaml.Interop) IEnumerable (System.Collections)
IBindableVector (Windows.UI.Xaml.Interop) IList (System.Collections)
TypeName (Windows.UI.Xaml.Interop) Type (System)

이름과 네임스페이스가 같은 형식

Type 네임스페이스
IPropertyValue Windows.Foundation
IReferenceArray<T> Windows.Foundation
Point Windows.Foundation
Rect Windows.Foundation
크기 Windows.Foundation
Color Windows.UI
TypeKind Windows.UI.Xaml.Interop

WinUI의 WinRT 형식에 대한 매핑

다른 이름 및/또는 네임스페이스를 가진 형식

WinRT 형식/네임스페이스 .NET 형식/네임스페이스
INotifyCollectionChanged(Microsoft.UI.Xaml.Data) INotifyCollectionChanged (System.Collections.Specialized)
NotifyCollectionChangedEventHandler(Microsoft.UI.Xaml.Data) NotifyCollectionChangedEventHandler (System.Collections.Specialized)
NotifyCollectionChangedEventArgs(Microsoft.UI.Xaml.Data) NotifyCollectionChangedEventArgs (System.Collections.Specialized)
NotifyCollectionChangedAction(Microsoft.UI.Xaml.Data) NotifyCollectionChangedAction (System.Collections.Specialized)
DataErrorsChangedEventArgs(Microsoft.UI.Xaml.Data) DataErrorsChangedEventArgs(System.ComponentModel)
INotifyDataErrorInfo(Microsoft.UI.Xaml.Data) INotifyDataErrorInfo(System.ComponentModel)
INotifyPropertyChanged(Microsoft.UI.Xaml.Data) INotifyPropertyChanged (System.ComponentModel)
PropertyChangedEventHandler(Microsoft.UI.Xaml.Data) PropertyChangedEventHandler (System.ComponentModel)
PropertyChangedEventArgs(Microsoft.UI.Xaml.Data) PropertyChangedEventArgs (System.ComponentModel)
ICommand(Microsoft.UI.Xaml.Input) ICommand(System.Windows.Input)
IXamlServiceProvider(Microsoft.UI.Xaml) IServiceProvider(시스템)

이름과 네임스페이스가 같은 형식

Type 네임스페이스
CornerRadius Microsoft.UI.Xaml
기간 Microsoft.UI.Xaml
DurationType Microsoft.UI.Xaml
GridLength Microsoft.UI.Xaml
GridUnitType Microsoft.UI.Xaml
두께 Microsoft.UI.Xaml
GeneratorPosition Microsoft.UI.Xaml.Controls.Primitives
행렬 Microsoft.UI.Xaml.Media
KeyTime Microsoft.UI.Xaml.Media.Animation
RepeatBehavior Microsoft.UI.Xaml.Media.Animation
RepeatBehaviorType Microsoft.UI.Xaml.Media.Animation
Matrix3D (Microsoft.UI.Xaml.Media.Media3D