Skip to content

Commit 1117a4a

Browse files
committed
Mark ToDictionary and GetProperties methods with RequiresUnreferencedCode
1 parent d398f62 commit 1117a4a

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

src/Jeffijoe.MessageFormat/Helpers/ObjectHelper.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System.Collections;
77
using System.Collections.Generic;
8+
using System.Diagnostics.CodeAnalysis;
89
using System.Linq;
910
using System.Reflection;
1011

@@ -26,6 +27,7 @@ internal static class ObjectHelper
2627
/// <returns>
2728
/// The <see cref="IEnumerable" />.
2829
/// </returns>
30+
[RequiresUnreferencedCode("This method uses reflection to read property information on object")]
2931
internal static IEnumerable<PropertyInfo> GetProperties(object obj)
3032
{
3133
var properties = new List<PropertyInfo>();
@@ -54,6 +56,7 @@ internal static IEnumerable<PropertyInfo> GetProperties(object obj)
5456
/// <returns>
5557
/// The <see cref="IDictionary" />.
5658
/// </returns>
59+
[RequiresUnreferencedCode("This method uses reflection to convert object into dictionary")]
5760
internal static Dictionary<string, object?> ToDictionary(this object obj)
5861
{
5962
// We want to be able to read the property, and it should not be an indexer.
@@ -69,4 +72,4 @@ internal static IEnumerable<PropertyInfo> GetProperties(object obj)
6972
}
7073

7174
#endregion
72-
}
75+
}

src/Jeffijoe.MessageFormat/Jeffijoe.MessageFormat.csproj

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
<SignAssembly>True</SignAssembly>
55
<AssemblyOriginatorKeyFile>MessageFormat.snk</AssemblyOriginatorKeyFile>
66
<PackageId>MessageFormat</PackageId>
7-
<GenerateAssemblyInfo>True</GenerateAssemblyInfo>
8-
<Authors>Jeff Hansen</Authors>
9-
<PackageTags>messageformat,messageformatter,xamarin,ui,messages,formatting,plural,pluralization,singular,select,strings,stringformat,format</PackageTags>
10-
<RepositoryUrl>https://github.com/jeffijoe/messageformat.net</RepositoryUrl>
11-
<LangVersion>latest</LangVersion>
12-
<Nullable>enable</Nullable>
13-
<TargetFrameworks>net6.0;net8.0;netstandard2.0;netstandard2.1</TargetFrameworks>
7+
<GenerateAssemblyInfo>True</GenerateAssemblyInfo>
8+
<Authors>Jeff Hansen</Authors>
9+
<PackageTags>messageformat,messageformatter,xamarin,ui,messages,formatting,plural,pluralization,singular,select,strings,stringformat,format</PackageTags>
10+
<RepositoryUrl>https://github.com/jeffijoe/messageformat.net</RepositoryUrl>
11+
<LangVersion>latest</LangVersion>
12+
<Nullable>enable</Nullable>
13+
<TargetFrameworks>net6.0;net8.0;netstandard2.0;netstandard2.1</TargetFrameworks>
1414
<PolySharpIncludeRuntimeSupportedAttributes>true</PolySharpIncludeRuntimeSupportedAttributes>
15+
<IsTrimmable>true</IsTrimmable>
1516
</PropertyGroup>
1617

1718
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">

src/Jeffijoe.MessageFormat/MessageFormatter.cs

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System;
77
using System.Collections.Generic;
88
using System.Collections.Concurrent;
9+
using System.Diagnostics.CodeAnalysis;
910
using System.Linq;
1011
using System.Text;
1112
using Jeffijoe.MessageFormat.Formatting;
@@ -202,6 +203,7 @@ public static string Format(string pattern, IReadOnlyDictionary<string, object?>
202203
/// <returns>
203204
/// The formatted message.
204205
/// </returns>
206+
[RequiresUnreferencedCode("This method uses the FormatMessage extension which uses reflection to convert object into dictionary")]
205207
public static string Format(string pattern, object data)
206208
{
207209
lock (Lock)

src/Jeffijoe.MessageFormat/MessageFormatterExtensions.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.Diagnostics.CodeAnalysis;
23
using Jeffijoe.MessageFormat.Helpers;
34

45
namespace Jeffijoe.MessageFormat;
@@ -46,6 +47,7 @@ public static string FormatMessage(
4647
/// <returns>
4748
/// The <see cref="string" />.
4849
/// </returns>
50+
[RequiresUnreferencedCode("This method uses the ToDictionary extension which uses reflection to convert object into dictionary")]
4951
public static string FormatMessage(this IMessageFormatter formatter, string pattern, object args)
5052
{
5153
return formatter.FormatMessage(pattern, args.ToDictionary());

0 commit comments

Comments
 (0)