| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,7 @@ public void Add(IPyObjectDecoder item) | |||
| 30 | 30 | public bool CanDecode(PyType objectType, Type targetType) | |
| 31 | 31 | => this.decoders.Any(decoder => decoder.CanDecode(objectType, targetType)); | |
| 32 | 32 | /// <inheritdoc /> | |
| 33 | - public bool TryDecode<T>(PyObject pyObj, out T value) | ||
| 33 | + public bool TryDecode<T>(PyObject pyObj, out T? value) | ||
| 34 | 34 | { | |
| 35 | 35 | if (pyObj is null) throw new ArgumentNullException(nameof(pyObj)); | |
| 36 | 36 | ||
@@ -65,7 +65,7 @@ public static class DecoderGroupExtensions | |||
| 65 | 65 | /// that can decode from <paramref name="objectType"/> to <paramref name="targetType"/>, | |
| 66 | 66 | /// or <c>null</c> if a matching decoder can not be found. | |
| 67 | 67 | /// </summary> | |
| 68 | - public static IPyObjectDecoder GetDecoder( | ||
| 68 | + public static IPyObjectDecoder? GetDecoder( | ||
| 69 | 69 | this IPyObjectDecoder decoder, | |
| 70 | 70 | PyType objectType, Type targetType) | |
| 71 | 71 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,7 +28,7 @@ public void Add(IPyObjectEncoder item) | |||
| 28 | 28 | /// <inheritdoc /> | |
| 29 | 29 | public bool CanEncode(Type type) => this.encoders.Any(encoder => encoder.CanEncode(type)); | |
| 30 | 30 | /// <inheritdoc /> | |
| 31 | - public PyObject TryEncode(object value) | ||
| 31 | + public PyObject? TryEncode(object value) | ||
| 32 | 32 | { | |
| 33 | 33 | if (value is null) throw new ArgumentNullException(nameof(value)); | |
| 34 | 34 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,7 +35,7 @@ public IEnumerator<T> GetEnumerator() | |||
| 35 | 35 | iterObject.Dispose(); | |
| 36 | 36 | break; | |
| 37 | 37 | } | |
| 38 | - yield return iterObject.Current.As<T>(); | ||
| 38 | + yield return iterObject.Current.As<T>()!; | ||
| 39 | 39 | } | |
| 40 | 40 | } | |
| 41 | 41 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,7 @@ public T this[int index] | |||
| 16 | 16 | { | |
| 17 | 17 | var item = Runtime.PyList_GetItem(pyObject, index); | |
| 18 | 18 | var pyItem = new PyObject(item); | |
| 19 | - return pyItem.As<T>(); | ||
| 19 | + return pyItem.As<T>()!; | ||
| 20 | 20 | } | |
| 21 | 21 | set | |
| 22 | 22 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -74,7 +74,7 @@ public static ICustomMarshaler GetInstance(string cookie) | |||
| 74 | 74 | return Instance; | |
| 75 | 75 | } | |
| 76 | 76 | ||
| 77 | - public static string PtrToStringUni(IntPtr p) | ||
| 77 | + public static string? PtrToStringUni(IntPtr p) | ||
| 78 | 78 | { | |
| 79 | 79 | if (p == IntPtr.Zero) | |
| 80 | 80 | { | |
@@ -134,7 +134,7 @@ public static IntPtr Py3UnicodePy2StringtoPtr(string s) | |||
| 134 | 134 | /// <returns> | |
| 135 | 135 | /// Managed String | |
| 136 | 136 | /// </returns> | |
| 137 | - public static string PtrToPy3UnicodePy2String(IntPtr p) | ||
| 137 | + public static string? PtrToPy3UnicodePy2String(IntPtr p) | ||
| 138 | 138 | { | |
| 139 | 139 | return PtrToStringUni(p); | |
| 140 | 140 | } | |
@@ -184,7 +184,7 @@ public override IntPtr MarshalManagedToNative(object managedObj) | |||
| 184 | 184 | return mem; | |
| 185 | 185 | } | |
| 186 | 186 | ||
| 187 | - public static ICustomMarshaler GetInstance(string cookie) | ||
| 187 | + public static ICustomMarshaler GetInstance(string? cookie) | ||
| 188 | 188 | { | |
| 189 | 189 | return Instance; | |
| 190 | 190 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -60,7 +60,8 @@ | |||
| 60 | 60 | </ItemGroup> | |
| 61 | 61 | ||
| 62 | 62 | <ItemGroup> | |
| 63 | + <PackageReference Include="Lost.Compat.NullabilityAttributes" Version="0.0.4" PrivateAssets="All" /> | ||
| 64 | + <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" /> | ||
| 63 | 65 | <PackageReference Include="System.Reflection.Emit" Version="4.3.0" /> | |
| 64 | - <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" /> | ||
| 65 | 66 | </ItemGroup> | |
| 66 | 67 | </Project> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -53,7 +53,9 @@ internal void Restore(InterDomainContext context) | |||
| 53 | 53 | { | |
| 54 | 54 | var cb = context.Storage.GetValue<ClassBase>("impl"); | |
| 55 | 55 | ||
| 56 | - cb.Load(this, context); | ||
| 56 | + Debug.Assert(cb is not null); | ||
| 57 | + | ||
| 58 | + cb!.Load(this, context); | ||
| 57 | 59 | ||
| 58 | 60 | Restore(cb); | |
| 59 | 61 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,11 @@ | |||
| 1 | 1 | using System.Collections.ObjectModel; | |
| 2 | + using System.Diagnostics.CodeAnalysis; | ||
| 2 | 3 | ||
| 3 | 4 | namespace Python.Runtime; | |
| 4 | 5 | ||
| 5 | 6 | public class CLRWrapperCollection : KeyedCollection<object, CLRMappedItem> | |
| 6 | 7 | { | |
| 7 | - public bool TryGetValue(object key, out CLRMappedItem value) | ||
| 8 | + public bool TryGetValue(object key, [NotNullWhen(true)] out CLRMappedItem? value) | ||
| 8 | 9 | { | |
| 9 | 10 | if (Dictionary == null) | |
| 10 | 11 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,10 @@ | |||
| 3 | 3 | ||
| 4 | 4 | namespace Python.Runtime.StateSerialization; | |
| 5 | 5 | ||
| 6 | + // Workaround for the lack of required properties: https://github.com/dotnet/csharplang/issues/3630 | ||
| 7 | + // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
| 8 | + #pragma warning disable CS8618 | ||
| 9 | + | ||
| 6 | 10 | [Serializable] | |
| 7 | 11 | internal class ClassManagerState | |
| 8 | 12 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,10 +3,14 @@ | |||
| 3 | 3 | ||
| 4 | 4 | namespace Python.Runtime.StateSerialization; | |
| 5 | 5 | ||
| 6 | + // Workaround for the lack of required properties: https://github.com/dotnet/csharplang/issues/3630 | ||
| 7 | + // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
| 8 | + #pragma warning disable CS8618 | ||
| 9 | + | ||
| 6 | 10 | [Serializable] | |
| 7 | 11 | internal class ImportHookState | |
| 8 | 12 | { | |
| 9 | - public PyModule PyCLRModule { get; set; } | ||
| 10 | - public PyObject Root { get; set; } | ||
| 11 | - public Dictionary<PyString, PyObject> Modules { get; set; } | ||
| 13 | + public PyModule PyCLRModule { get; init; } | ||
| 14 | + public PyObject Root { get; init; } | ||
| 15 | + public Dictionary<PyString, PyObject> Modules { get; init; } | ||
| 12 | 16 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments