-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable property visibility tests in source-gen mode (#54526)
* Enable property visibility tests in source-gen mode * Address feedback * Fix S.N.H.Json tests * Fix S.T.J tests * Fix S.N.H.J tests ii
- Loading branch information
Showing
67 changed files
with
4,140 additions
and
3,024 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace System.Text.Json | ||
{ | ||
internal static partial class JsonHelpers | ||
{ | ||
/// <summary> | ||
/// Emulates Dictionary.TryAdd on netstandard. | ||
/// </summary> | ||
public static bool TryAdd<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, in TKey key, in TValue value) where TKey : notnull | ||
{ | ||
#if NETSTANDARD2_0 || NETFRAMEWORK | ||
if (!dictionary.ContainsKey(key)) | ||
{ | ||
dictionary[key] = value; | ||
return true; | ||
} | ||
|
||
return false; | ||
#else | ||
return dictionary.TryAdd(key, value); | ||
#endif | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/libraries/System.Text.Json/Common/ReflectionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Diagnostics; | ||
using System.Reflection; | ||
|
||
namespace System.Text.Json.Reflection | ||
{ | ||
internal static partial class ReflectionExtensions | ||
{ | ||
public static bool IsVirtual(this PropertyInfo? propertyInfo) | ||
{ | ||
Debug.Assert(propertyInfo != null); | ||
return propertyInfo != null && (propertyInfo.GetMethod?.IsVirtual == true || propertyInfo.SetMethod?.IsVirtual == true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.