Skip to content

Commit c29a341

Browse files
authored
Add some [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] annotations (#839)
* ... * [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] * <!--<IsTrimmable>true</IsTrimmable>--> * fix * fix ca * 5 * fx * fixed some warnings * . * .
1 parent 206e7ae commit c29a341

35 files changed

+793
-577
lines changed

System.Linq.Dynamic.Core.sln

+19
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Dynamic.Core.Te
145145
EndProject
146146
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WasmDynamicLinq", "src-blazor\WasmDynamicLinq\WasmDynamicLinq.csproj", "{2DE2052F-0A50-40C7-B6FF-52B52386BF9A}"
147147
EndProject
148+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SldcTrimmer", "src-examples\SldcTrimmer\SldcTrimmer.csproj", "{7A31366C-DD98-41A3-A0C1-A97068BD9658}"
149+
EndProject
148150
Global
149151
GlobalSection(SolutionConfigurationPlatforms) = preSolution
150152
Debug|Any CPU = Debug|Any CPU
@@ -913,6 +915,22 @@ Global
913915
{2DE2052F-0A50-40C7-B6FF-52B52386BF9A}.Release|x64.Build.0 = Release|Any CPU
914916
{2DE2052F-0A50-40C7-B6FF-52B52386BF9A}.Release|x86.ActiveCfg = Release|Any CPU
915917
{2DE2052F-0A50-40C7-B6FF-52B52386BF9A}.Release|x86.Build.0 = Release|Any CPU
918+
{7A31366C-DD98-41A3-A0C1-A97068BD9658}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
919+
{7A31366C-DD98-41A3-A0C1-A97068BD9658}.Debug|Any CPU.Build.0 = Debug|Any CPU
920+
{7A31366C-DD98-41A3-A0C1-A97068BD9658}.Debug|ARM.ActiveCfg = Debug|Any CPU
921+
{7A31366C-DD98-41A3-A0C1-A97068BD9658}.Debug|ARM.Build.0 = Debug|Any CPU
922+
{7A31366C-DD98-41A3-A0C1-A97068BD9658}.Debug|x64.ActiveCfg = Debug|Any CPU
923+
{7A31366C-DD98-41A3-A0C1-A97068BD9658}.Debug|x64.Build.0 = Debug|Any CPU
924+
{7A31366C-DD98-41A3-A0C1-A97068BD9658}.Debug|x86.ActiveCfg = Debug|Any CPU
925+
{7A31366C-DD98-41A3-A0C1-A97068BD9658}.Debug|x86.Build.0 = Debug|Any CPU
926+
{7A31366C-DD98-41A3-A0C1-A97068BD9658}.Release|Any CPU.ActiveCfg = Release|Any CPU
927+
{7A31366C-DD98-41A3-A0C1-A97068BD9658}.Release|Any CPU.Build.0 = Release|Any CPU
928+
{7A31366C-DD98-41A3-A0C1-A97068BD9658}.Release|ARM.ActiveCfg = Release|Any CPU
929+
{7A31366C-DD98-41A3-A0C1-A97068BD9658}.Release|ARM.Build.0 = Release|Any CPU
930+
{7A31366C-DD98-41A3-A0C1-A97068BD9658}.Release|x64.ActiveCfg = Release|Any CPU
931+
{7A31366C-DD98-41A3-A0C1-A97068BD9658}.Release|x64.Build.0 = Release|Any CPU
932+
{7A31366C-DD98-41A3-A0C1-A97068BD9658}.Release|x86.ActiveCfg = Release|Any CPU
933+
{7A31366C-DD98-41A3-A0C1-A97068BD9658}.Release|x86.Build.0 = Release|Any CPU
916934
EndGlobalSection
917935
GlobalSection(SolutionProperties) = preSolution
918936
HideSolutionNode = FALSE
@@ -965,6 +983,7 @@ Global
965983
{B01B327C-FC68-49B6-BDE3-A13D0C66DF5C} = {7971CAEB-B9F2-416B-966D-2D697C4C1E62}
966984
{7AFC2836-0F6E-4B0D-8BB3-13317A3B6616} = {8463ED7E-69FB-49AE-85CF-0791AFD98E38}
967985
{2DE2052F-0A50-40C7-B6FF-52B52386BF9A} = {122BC4FA-7563-4E35-9D17-077F16F1629F}
986+
{7A31366C-DD98-41A3-A0C1-A97068BD9658} = {BCA2A024-9032-4E56-A6C4-17A15D921728}
968987
EndGlobalSection
969988
GlobalSection(ExtensibilityGlobals) = postSolution
970989
SolutionGuid = {94C56722-194E-4B8B-BC23-B3F754E89A20}

System.Linq.Dynamic.Core.sln.DotSettings

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IL/@EntryIndexedValue">IL</s:String>
44
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=UTC/@EntryIndexedValue">UTC</s:String>
55
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WASM/@EntryIndexedValue">WASM</s:String>
6+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Corelib/@EntryIndexedValue">True</s:Boolean>
67
<s:Boolean x:Key="/Default/UserDictionary/Words/=DLL_0027s/@EntryIndexedValue">True</s:Boolean>
78
<s:Boolean x:Key="/Default/UserDictionary/Words/=Formattable/@EntryIndexedValue">True</s:Boolean>
89
<s:Boolean x:Key="/Default/UserDictionary/Words/=ilgenerator/@EntryIndexedValue">True</s:Boolean>

src-examples/SldcTrimmer/Color.cs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace SldcTrimmer
2+
{
3+
internal class Color
4+
{
5+
public byte Alpha { get; set; }
6+
public byte Red { get; set; }
7+
public byte Green { get; set; }
8+
public byte Blue { get; set; }
9+
public float Hue { get; set; }
10+
public float Saturation { get; set; }
11+
public float Brightness { get; set; }
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Linq.Dynamic.Core;
3+
4+
namespace SldcTrimmer
5+
{
6+
internal static class LambdaExtensions
7+
{
8+
public static Func<T1, T2> ParseLambda<T1, T2>(this string expression)
9+
{
10+
return DynamicExpressionParser.ParseLambda<T1, T2>(null, false, expression).Compile();
11+
}
12+
}
13+
}

src-examples/SldcTrimmer/Program.cs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
3+
namespace SldcTrimmer
4+
{
5+
class Program
6+
{
7+
static void Main(string[] args)
8+
{
9+
try
10+
{
11+
const string filterStr = "Alpha == 255";
12+
Console.WriteLine(filterStr);
13+
14+
var filter = filterStr.ParseLambda<Color, bool>();
15+
16+
var color1 = new Color { Alpha = 255 };
17+
var value1 = filter(color1);
18+
Console.WriteLine($"{color1.Alpha} -> {value1}");
19+
20+
var color2 = new Color { Alpha = 128 };
21+
var value2 = filter(color2);
22+
Console.WriteLine($"{color2.Alpha} -> {value2}");
23+
}
24+
catch (Exception e)
25+
{
26+
Console.WriteLine(e.GetType());
27+
Console.WriteLine(e.Message);
28+
Console.WriteLine(e.StackTrace);
29+
}
30+
}
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project>
6+
<PropertyGroup>
7+
<Configuration>Release</Configuration>
8+
<Platform>Any CPU</Platform>
9+
<PublishDir>C:\temp\x</PublishDir>
10+
<PublishProtocol>FileSystem</PublishProtocol>
11+
<_TargetId>Folder</_TargetId>
12+
<TargetFramework>net8.0</TargetFramework>
13+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
14+
<SelfContained>true</SelfContained>
15+
<PublishSingleFile>true</PublishSingleFile>
16+
<PublishReadyToRun>true</PublishReadyToRun>
17+
</PropertyGroup>
18+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<PropertyGroup>
9+
<PublishTrimmed>true</PublishTrimmed>
10+
<TrimMode>full</TrimMode>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<ProjectReference Include="..\..\src\System.Linq.Dynamic.Core\System.Linq.Dynamic.Core.csproj" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<!--<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.5" />-->
19+
<TrimmerRootAssembly Include="System.Linq.Dynamic.Core" />
20+
</ItemGroup>
21+
22+
</Project>

src/System.Linq.Dynamic.Core/AnyOfTypes/AnyOfTypes.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ namespace AnyOfTypes
1111
{
1212
internal enum AnyOfType
1313
{
14-
Undefined = 0, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth
14+
Undefined = 0, First, Second
1515
}
1616
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#if !NET6_0_OR_GREATER
2+
3+
// ReSharper disable once CheckNamespace
4+
namespace System.Diagnostics.CodeAnalysis;
5+
6+
//
7+
// Summary:
8+
// Specifies the types of members that are dynamically accessed. This enumeration
9+
// has a System.FlagsAttribute attribute that allows a bitwise combination of its
10+
// member values.
11+
[Flags]
12+
internal enum DynamicallyAccessedMemberTypes
13+
{
14+
//
15+
// Summary:
16+
// Specifies all members.
17+
All = -1,
18+
//
19+
// Summary:
20+
// Specifies no members.
21+
None = 0,
22+
//
23+
// Summary:
24+
// Specifies the default, parameterless public constructor.
25+
PublicParameterlessConstructor = 1,
26+
//
27+
// Summary:
28+
// Specifies all public constructors.
29+
PublicConstructors = 3,
30+
//
31+
// Summary:
32+
// Specifies all non-public constructors.
33+
NonPublicConstructors = 4,
34+
//
35+
// Summary:
36+
// Specifies all public methods.
37+
PublicMethods = 8,
38+
//
39+
// Summary:
40+
// Specifies all non-public methods.
41+
NonPublicMethods = 16,
42+
//
43+
// Summary:
44+
// Specifies all public fields.
45+
PublicFields = 32,
46+
//
47+
// Summary:
48+
// Specifies all non-public fields.
49+
NonPublicFields = 64,
50+
//
51+
// Summary:
52+
// Specifies all public nested types.
53+
PublicNestedTypes = 128,
54+
//
55+
// Summary:
56+
// Specifies all non-public nested types.
57+
NonPublicNestedTypes = 256,
58+
//
59+
// Summary:
60+
// Specifies all public properties.
61+
PublicProperties = 512,
62+
//
63+
// Summary:
64+
// Specifies all non-public properties.
65+
NonPublicProperties = 1024,
66+
//
67+
// Summary:
68+
// Specifies all public events.
69+
PublicEvents = 2048,
70+
//
71+
// Summary:
72+
// Specifies all non-public events.
73+
NonPublicEvents = 4096,
74+
//
75+
// Summary:
76+
// Specifies all interfaces implemented by the type.
77+
Interfaces = 8192
78+
}
79+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#if !NET6_0_OR_GREATER
2+
3+
// ReSharper disable once CheckNamespace
4+
namespace System.Diagnostics.CodeAnalysis;
5+
6+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, Inherited = false)]
7+
internal sealed class DynamicallyAccessedMembersAttribute : Attribute
8+
{
9+
public DynamicallyAccessedMembersAttribute(DynamicallyAccessedMemberTypes memberTypes)
10+
{
11+
MemberTypes = memberTypes;
12+
}
13+
14+
public DynamicallyAccessedMemberTypes MemberTypes { get; }
15+
}
16+
#endif

0 commit comments

Comments
 (0)