2828#nullable enable
2929
3030using System ;
31+ using System . ComponentModel ;
32+
3133using CoreFoundation ;
3234using CoreText ;
3335using ObjCRuntime ;
@@ -46,7 +48,7 @@ public partial class NSAttributedString {
4648 /// <param name="options">A dictionary of attributes that specifies how to interpret the document contents.</param>
4749 /// <param name="resultDocumentAttributes">Upon return, a dictionary of document-specific keys.</param>
4850 /// <param name="error">The error if an error occurred.</param>
49- public static NSAttributedString ? Create ( NSUrl url , NSDictionary options , out NSDictionary resultDocumentAttributes , out NSError error )
51+ public static NSAttributedString ? Create ( NSUrl url , NSDictionary options , out NSDictionary resultDocumentAttributes , out NSError ? error )
5052 {
5153 var rv = new NSAttributedString ( NSObjectFlag . Empty ) ;
5254 rv . InitializeHandle ( rv . _InitWithUrl ( url , options , out resultDocumentAttributes , out error ) , string . Empty , false ) ;
@@ -62,17 +64,34 @@ public partial class NSAttributedString {
6264 /// <param name="options">A dictionary of attributes that specifies how to interpret the document contents.</param>
6365 /// <param name="resultDocumentAttributes">Upon return, a dictionary of document-specific keys.</param>
6466 /// <param name="error">The error if an error occurred.</param>
65- public static NSAttributedString ? Create ( NSUrl url , NSAttributedStringDocumentAttributes options , out NSDictionary resultDocumentAttributes , out NSError error )
67+ public static NSAttributedString ? Create ( NSUrl url , NSAttributedStringDocumentAttributes options , out NSDictionary resultDocumentAttributes , out NSError ? error )
6668 {
6769 return Create ( url , options . Dictionary , out resultDocumentAttributes , out error ) ;
6870 }
6971
72+ /// <summary>Create a new <see cref="NSAttributedString" />.</summary>
73+ /// <param name="url">A url to the document to load.</param>
74+ /// <param name="options">A dictionary of attributes that specifies how to interpret the document contents.</param>
75+ /// <param name="error">The error if an error occurred.</param>
76+ public static NSAttributedString ? Create ( NSUrl url , NSAttributedStringDocumentAttributes options , out NSError ? error )
77+ {
78+ return Create ( url , options . Dictionary , out var _ , out error ) ;
79+ }
80+
81+ /// <summary>Create a new <see cref="NSAttributedString" />.</summary>
82+ /// <param name="url">A url to the document to load.</param>
83+ /// <param name="error">The error if an error occurred.</param>
84+ public static NSAttributedString ? Create ( NSUrl url , out NSError ? error )
85+ {
86+ return Create ( url , new NSDictionary ( ) , out var _ , out error ) ;
87+ }
88+
7089 /// <summary>Create a new <see cref="NSAttributedString" />.</summary>
7190 /// <param name="data">The data to load.</param>
7291 /// <param name="options">A dictionary of attributes that specifies how to interpret the document contents.</param>
7392 /// <param name="resultDocumentAttributes">Upon return, a dictionary of document-specific keys.</param>
7493 /// <param name="error">The error if an error occurred.</param>
75- public static NSAttributedString ? Create ( NSData data , NSDictionary options , out NSDictionary resultDocumentAttributes , out NSError error )
94+ public static NSAttributedString ? Create ( NSData data , NSDictionary options , out NSDictionary resultDocumentAttributes , out NSError ? error )
7695 {
7796 var rv = new NSAttributedString ( NSObjectFlag . Empty ) ;
7897 rv . InitializeHandle ( rv . _InitWithData ( data , options , out resultDocumentAttributes , out error ) , string . Empty , false ) ;
@@ -88,33 +107,114 @@ public partial class NSAttributedString {
88107 /// <param name="options">A dictionary of attributes that specifies how to interpret the document contents.</param>
89108 /// <param name="resultDocumentAttributes">Upon return, a dictionary of document-specific keys.</param>
90109 /// <param name="error">The error if an error occurred.</param>
91- public static NSAttributedString ? Create ( NSData data , NSAttributedStringDocumentAttributes options , out NSDictionary resultDocumentAttributes , out NSError error )
110+ public static NSAttributedString ? Create ( NSData data , NSAttributedStringDocumentAttributes options , out NSDictionary resultDocumentAttributes , out NSError ? error )
92111 {
93112 return Create ( data , options . Dictionary , out resultDocumentAttributes , out error ) ;
94113 }
95114
115+ /// <summary>Create a new <see cref="NSAttributedString" />.</summary>
116+ /// <param name="data">The data to load.</param>
117+ /// <param name="options">A dictionary of attributes that specifies how to interpret the document contents.</param>
118+ /// <param name="error">The error if an error occurred.</param>
119+ public static NSAttributedString ? Create ( NSData data , NSAttributedStringDocumentAttributes options , out NSError ? error )
120+ {
121+ return Create ( data , options . Dictionary , out var _ , out error ) ;
122+ }
123+
124+ /// <summary>Create a new <see cref="NSAttributedString" />.</summary>
125+ /// <param name="data">The data to load.</param>
126+ /// <param name="error">The error if an error occurred.</param>
127+ public static NSAttributedString ? Create ( NSData data , out NSError ? error )
128+ {
129+ return Create ( data , new NSDictionary ( ) , out var _ , out error ) ;
130+ }
131+
132+ /// <summary>Create a new <see cref="NSAttributedString" /> from a markdown file.</summary>
133+ /// <param name="markdownFile">The url of the file to load.</param>
134+ /// <param name="options">A dictionary of attributes that specifies how to interpret the document contents.</param>
135+ /// <param name="baseUrl">The base url to use when resolving markdown urls.</param>
136+ /// <param name="error">The error if an error occurred.</param>
137+ public static NSAttributedString ? Create ( NSUrl markdownFile , NSAttributedStringMarkdownParsingOptions ? options , NSUrl ? baseUrl , out NSError ? error )
138+ {
139+ var rv = new NSAttributedString ( NSObjectFlag . Empty ) ;
140+ rv . InitializeHandle ( rv . _InitWithContentsOfMarkdownFile ( markdownFile , options , baseUrl , out error ) , string . Empty , false ) ;
141+ if ( rv . Handle == IntPtr . Zero ) {
142+ rv . Dispose ( ) ;
143+ return null ;
144+ }
145+ return rv ;
146+ }
147+
148+ /// <summary>Create a new <see cref="NSAttributedString" /> from markdown data.</summary>
149+ /// <param name="markdown">The markdown data to load.</param>
150+ /// <param name="options">A dictionary of attributes that specifies how to interpret the document contents.</param>
151+ /// <param name="baseUrl">The base url to use when resolving markdown urls.</param>
152+ /// <param name="error">The error if an error occurred.</param>
153+ public static NSAttributedString ? Create ( NSData markdown , NSAttributedStringMarkdownParsingOptions ? options , NSUrl ? baseUrl , out NSError ? error )
154+ {
155+ var rv = new NSAttributedString ( NSObjectFlag . Empty ) ;
156+ rv . InitializeHandle ( rv . _InitWithMarkdown ( markdown , options , baseUrl , out error ) , string . Empty , false ) ;
157+ if ( rv . Handle == IntPtr . Zero ) {
158+ rv . Dispose ( ) ;
159+ return null ;
160+ }
161+ return rv ;
162+ }
163+
164+ /// <summary>Create a new <see cref="NSAttributedString" /> from a string with markdown.</summary>
165+ /// <param name="markdownString">The markdown string to load.</param>
166+ /// <param name="options">A dictionary of attributes that specifies how to interpret the document contents.</param>
167+ /// <param name="baseUrl">The base url to use when resolving markdown urls.</param>
168+ /// <param name="error">The error if an error occurred.</param>
169+ public static NSAttributedString ? Create ( string markdownString , NSAttributedStringMarkdownParsingOptions ? options , NSUrl ? baseUrl , out NSError ? error )
170+ {
171+ var rv = new NSAttributedString ( NSObjectFlag . Empty ) ;
172+ rv . InitializeHandle ( rv . _InitWithMarkdownString ( markdownString , options , baseUrl , out error ) , string . Empty , false ) ;
173+ if ( rv . Handle == IntPtr . Zero ) {
174+ rv . Dispose ( ) ;
175+ return null ;
176+ }
177+ return rv ;
178+ }
179+
96180#if __MACOS__ || XAMCORE_5_0
181+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
182+ [ Obsolete ( "Use the 'Create' method instead, because there's no way to return an error from a constructor." ) ]
97183 public NSAttributedString ( NSUrl url , NSAttributedStringDocumentAttributes documentAttributes , out NSError error )
98184 : this ( url , documentAttributes , out var _ , out error ) { }
99185
186+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
187+ [ Obsolete ( "Use the 'Create' method instead, because there's no way to return an error from a constructor." ) ]
100188 public NSAttributedString ( NSData data , NSAttributedStringDocumentAttributes documentAttributes , out NSError error )
101189 : this ( data , documentAttributes , out var _ , out error ) { }
102190
191+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
192+ [ Obsolete ( "Use the 'Create' method instead, because there's no way to return an error from a constructor." ) ]
103193 public NSAttributedString ( NSUrl url , out NSError error )
104194 : this ( url , new NSDictionary ( ) , out var _ , out error ) { }
105195
196+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
197+ [ Obsolete ( "Use the 'Create' method instead, because there's no way to return an error from a constructor." ) ]
106198 public NSAttributedString ( NSData data , out NSError error )
107199 : this ( data , new NSDictionary ( ) , out var _ , out error ) { }
108200#else
201+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
202+ [ Obsolete ( "Use the 'Create' method instead, because there's no way to return an error from a constructor." ) ]
109203 public NSAttributedString ( NSUrl url , NSAttributedStringDocumentAttributes documentAttributes , ref NSError error )
110204 : this ( url , documentAttributes , out var _ , ref error ) { }
111205
206+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
207+ [ Obsolete ( "Use the 'Create' method instead, because there's no way to return an error from a constructor." ) ]
112208 public NSAttributedString ( NSData data , NSAttributedStringDocumentAttributes documentAttributes , ref NSError error )
113209 : this ( data , documentAttributes , out var _ , ref error ) { }
114210
211+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
212+ [ Obsolete ( "Use the 'Create' method instead, because there's no way to return an error from a constructor." ) ]
115213 public NSAttributedString ( NSUrl url , ref NSError error )
116214 : this ( url , new NSDictionary ( ) , out var _ , ref error ) { }
117215
216+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
217+ [ Obsolete ( "Use the 'Create' method instead, because there's no way to return an error from a constructor." ) ]
118218 public NSAttributedString ( NSData data , ref NSError error )
119219 : this ( data , new NSDictionary ( ) , out var _ , ref error ) { }
120220#endif
0 commit comments