-
-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.A…
…ll)] annotations (#839) * ... * [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] * <!--<IsTrimmable>true</IsTrimmable>--> * fix * fix ca * 5 * fx * fixed some warnings * . * .
- Loading branch information
Showing
35 changed files
with
793 additions
and
577 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
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,13 @@ | ||
namespace SldcTrimmer | ||
{ | ||
internal class Color | ||
{ | ||
public byte Alpha { get; set; } | ||
public byte Red { get; set; } | ||
public byte Green { get; set; } | ||
public byte Blue { get; set; } | ||
public float Hue { get; set; } | ||
public float Saturation { get; set; } | ||
public float Brightness { get; set; } | ||
} | ||
} |
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,13 @@ | ||
using System; | ||
using System.Linq.Dynamic.Core; | ||
|
||
namespace SldcTrimmer | ||
{ | ||
internal static class LambdaExtensions | ||
{ | ||
public static Func<T1, T2> ParseLambda<T1, T2>(this string expression) | ||
{ | ||
return DynamicExpressionParser.ParseLambda<T1, T2>(null, false, expression).Compile(); | ||
} | ||
} | ||
} |
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,32 @@ | ||
using System; | ||
|
||
namespace SldcTrimmer | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
try | ||
{ | ||
const string filterStr = "Alpha == 255"; | ||
Console.WriteLine(filterStr); | ||
|
||
var filter = filterStr.ParseLambda<Color, bool>(); | ||
|
||
var color1 = new Color { Alpha = 255 }; | ||
var value1 = filter(color1); | ||
Console.WriteLine($"{color1.Alpha} -> {value1}"); | ||
|
||
var color2 = new Color { Alpha = 128 }; | ||
var value2 = filter(color2); | ||
Console.WriteLine($"{color2.Alpha} -> {value2}"); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine(e.GetType()); | ||
Console.WriteLine(e.Message); | ||
Console.WriteLine(e.StackTrace); | ||
} | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src-examples/SldcTrimmer/Properties/PublishProfiles/FolderProfile.pubxml
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,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
https://go.microsoft.com/fwlink/?LinkID=208121. | ||
--> | ||
<Project> | ||
<PropertyGroup> | ||
<Configuration>Release</Configuration> | ||
<Platform>Any CPU</Platform> | ||
<PublishDir>C:\temp\x</PublishDir> | ||
<PublishProtocol>FileSystem</PublishProtocol> | ||
<_TargetId>Folder</_TargetId> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RuntimeIdentifier>win-x64</RuntimeIdentifier> | ||
<SelfContained>true</SelfContained> | ||
<PublishSingleFile>true</PublishSingleFile> | ||
<PublishReadyToRun>true</PublishReadyToRun> | ||
</PropertyGroup> | ||
</Project> |
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,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<PublishTrimmed>true</PublishTrimmed> | ||
<TrimMode>full</TrimMode> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\System.Linq.Dynamic.Core\System.Linq.Dynamic.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<!--<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.5" />--> | ||
<TrimmerRootAssembly Include="System.Linq.Dynamic.Core" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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
79 changes: 79 additions & 0 deletions
79
src/System.Linq.Dynamic.Core/Compatibility/CodeAnalysis/DynamicallyAccessedMemberTypes.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,79 @@ | ||
#if !NET6_0_OR_GREATER | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace System.Diagnostics.CodeAnalysis; | ||
|
||
// | ||
// Summary: | ||
// Specifies the types of members that are dynamically accessed. This enumeration | ||
// has a System.FlagsAttribute attribute that allows a bitwise combination of its | ||
// member values. | ||
[Flags] | ||
internal enum DynamicallyAccessedMemberTypes | ||
{ | ||
// | ||
// Summary: | ||
// Specifies all members. | ||
All = -1, | ||
// | ||
// Summary: | ||
// Specifies no members. | ||
None = 0, | ||
// | ||
// Summary: | ||
// Specifies the default, parameterless public constructor. | ||
PublicParameterlessConstructor = 1, | ||
// | ||
// Summary: | ||
// Specifies all public constructors. | ||
PublicConstructors = 3, | ||
// | ||
// Summary: | ||
// Specifies all non-public constructors. | ||
NonPublicConstructors = 4, | ||
// | ||
// Summary: | ||
// Specifies all public methods. | ||
PublicMethods = 8, | ||
// | ||
// Summary: | ||
// Specifies all non-public methods. | ||
NonPublicMethods = 16, | ||
// | ||
// Summary: | ||
// Specifies all public fields. | ||
PublicFields = 32, | ||
// | ||
// Summary: | ||
// Specifies all non-public fields. | ||
NonPublicFields = 64, | ||
// | ||
// Summary: | ||
// Specifies all public nested types. | ||
PublicNestedTypes = 128, | ||
// | ||
// Summary: | ||
// Specifies all non-public nested types. | ||
NonPublicNestedTypes = 256, | ||
// | ||
// Summary: | ||
// Specifies all public properties. | ||
PublicProperties = 512, | ||
// | ||
// Summary: | ||
// Specifies all non-public properties. | ||
NonPublicProperties = 1024, | ||
// | ||
// Summary: | ||
// Specifies all public events. | ||
PublicEvents = 2048, | ||
// | ||
// Summary: | ||
// Specifies all non-public events. | ||
NonPublicEvents = 4096, | ||
// | ||
// Summary: | ||
// Specifies all interfaces implemented by the type. | ||
Interfaces = 8192 | ||
} | ||
#endif |
16 changes: 16 additions & 0 deletions
16
...ystem.Linq.Dynamic.Core/Compatibility/CodeAnalysis/DynamicallyAccessedMembersAttribute.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,16 @@ | ||
#if !NET6_0_OR_GREATER | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace System.Diagnostics.CodeAnalysis; | ||
|
||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, Inherited = false)] | ||
internal sealed class DynamicallyAccessedMembersAttribute : Attribute | ||
{ | ||
public DynamicallyAccessedMembersAttribute(DynamicallyAccessedMemberTypes memberTypes) | ||
{ | ||
MemberTypes = memberTypes; | ||
} | ||
|
||
public DynamicallyAccessedMemberTypes MemberTypes { get; } | ||
} | ||
#endif |
File renamed without changes.
Oops, something went wrong.