forked from reactiveui/ReactiveUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: bring reactiveui.fody into the main project (reactiveui#1503)
* added fody * Fix unhandled exception on netstandard (reactiveui#1578) * Align Fody dependencies to ReactiveUI (reactiveui#1649) * added @reactiveui/fody-team * Finish up ReactiveUI.Fody (reactiveui#1671) * Fix package versioning * Fix ReactiveUI.Fody NuGet package and include tests in build * Add Fody projects to solution * Fixed CLI build for Fody * Added another Reactive Test
- Loading branch information
1 parent
53151e2
commit cd92852
Showing
31 changed files
with
1,579 additions
and
3 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
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
13 changes: 13 additions & 0 deletions
13
src/ReactiveUI.Fody.Helpers/ObservableAsPropertyAttribute.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,13 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MS-PL license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
|
||
namespace ReactiveUI.Fody.Helpers | ||
{ | ||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] | ||
public class ObservableAsPropertyAttribute : Attribute | ||
{ | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/ReactiveUI.Fody.Helpers/ObservableAsPropertyExtensions.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,41 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MS-PL license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Linq.Expressions; | ||
using System.Reactive.Concurrency; | ||
using System.Reflection; | ||
|
||
namespace ReactiveUI.Fody.Helpers | ||
{ | ||
public static class ObservableAsPropertyExtensions | ||
{ | ||
public static ObservableAsPropertyHelper<TRet> ToPropertyEx<TObj, TRet>(this IObservable<TRet> @this, TObj source, Expression<Func<TObj, TRet>> property, TRet initialValue = default(TRet), bool deferSubscription = false, IScheduler scheduler = null) where TObj : ReactiveObject | ||
{ | ||
var result = @this.ToProperty(source, property, initialValue, deferSubscription, scheduler); | ||
|
||
// Now assign the field via reflection. | ||
var propertyInfo = property.GetPropertyInfo(); | ||
if (propertyInfo == null) | ||
throw new Exception("Could not resolve expression " + property + " into a property."); | ||
|
||
var field = propertyInfo.DeclaringType.GetTypeInfo().GetDeclaredField("$" + propertyInfo.Name); | ||
if (field == null) | ||
throw new Exception("Backing field not found for " + propertyInfo); | ||
field.SetValue(source, result); | ||
|
||
return result; | ||
} | ||
|
||
static PropertyInfo GetPropertyInfo(this LambdaExpression expression) | ||
{ | ||
var current = expression.Body; | ||
var unary = current as UnaryExpression; | ||
if (unary != null) | ||
current = unary.Operand; | ||
var call = (MemberExpression)current; | ||
return (PropertyInfo)call.Member; | ||
} | ||
} | ||
} |
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,11 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MS-PL license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("ReactiveUI.Tests")] | ||
[assembly: InternalsVisibleTo("ReactiveUI.Winforms")] | ||
[assembly: InternalsVisibleTo("ReactiveUI.Wpf")] | ||
[assembly: InternalsVisibleTo("ReactiveUI.XamForms")] | ||
[assembly: InternalsVisibleTo("ReactiveUI.AndroidSupport")] |
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 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MS-PL license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
|
||
namespace ReactiveUI.Fody.Helpers | ||
{ | ||
[AttributeUsage(AttributeTargets.Property)] | ||
public class ReactiveAttribute : Attribute | ||
{ | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/ReactiveUI.Fody.Helpers/ReactiveDependencyAttribute.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,31 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MS-PL license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace ReactiveUI.Fody.Helpers | ||
{ | ||
[AttributeUsage(AttributeTargets.Property)] | ||
public class ReactiveDependencyAttribute : Attribute | ||
{ | ||
private readonly string _targetName; | ||
|
||
public ReactiveDependencyAttribute(string targetName) | ||
{ | ||
_targetName = targetName; | ||
} | ||
|
||
/// <summary> | ||
/// The name of the backing property | ||
/// </summary> | ||
public string Target => _targetName; | ||
|
||
/// <summary> | ||
/// Target property on the backing property | ||
/// </summary> | ||
public string TargetProperty { get; set; } | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/ReactiveUI.Fody.Helpers/ReactiveUI.Fody.Helpers.csproj
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,51 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;net461;uap10.0.16299;Xamarin.iOS10;Xamarin.Mac20;MonoAndroid80;netcoreapp2.0</TargetFrameworks> | ||
<AssemblyName>ReactiveUI.Fody.Helpers</AssemblyName> | ||
<RootNamespace>ReactiveUI.Fody.Helpers</RootNamespace> | ||
<Description>Fody extension to generate RaisePropertyChange notifications for properties and ObservableAsPropertyHelper properties.</Description> | ||
|
||
<!-- Override FodyPackaging since project is named differently than expected --> | ||
<PackageId>ReactiveUI.Fody</PackageId> | ||
<WeaverDirPath>..\$(PackageId)\bin\$(Configuration)\</WeaverDirPath> | ||
<GeneratePackageOnBuild>False</GeneratePackageOnBuild> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Fody" Version="3.0.3" PrivateAssets="None" /> | ||
<PackageReference Include="FodyPackaging" Version="3.0.3" PrivateAssets="All" /> | ||
<PackageReference Include="System.Reactive" Version="[3.1.1,4)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="$(TargetFramework.StartsWith('netstandard'))"> | ||
<PackageReference Include="System.ComponentModel" Version="4.3.0" /> | ||
<PackageReference Include="System.Diagnostics.Contracts" Version="4.3.0" /> | ||
<PackageReference Include="System.Dynamic.Runtime" Version="4.3.0" /> | ||
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.iOS'))"> | ||
<Reference Include="System.Runtime.Serialization" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac'))"> | ||
<Reference Include="System.Runtime.Serialization" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="$(TargetFramework.StartsWith('MonoAndroid'))"> | ||
<Reference Include="System.Runtime.Serialization" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="$(TargetFramework.StartsWith('netcoreapp'))"> | ||
<PackageReference Include="System.ComponentModel" Version="4.3.0" /> | ||
<PackageReference Include="System.Diagnostics.Contracts" Version="4.3.0" /> | ||
<PackageReference Include="System.Dynamic.Runtime" Version="4.3.0" /> | ||
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ReactiveUI\ReactiveUI.csproj" /> | ||
</ItemGroup> | ||
|
||
<Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" /> | ||
</Project> |
12 changes: 12 additions & 0 deletions
12
src/ReactiveUI.Fody.Helpers/ReactiveUI.Fody.Helpers.licenseheader
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,12 @@ | ||
extensions: designer.cs generated.cs | ||
extensions: .cs | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MS-PL license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
extensions: .xml .config .xsd | ||
<!-- | ||
Licensed to the .NET Foundation under one or more agreements. | ||
The .NET Foundation licenses this file to you under the MS-PL license. | ||
See the LICENSE file in the project root for more information. | ||
--> |
31 changes: 31 additions & 0 deletions
31
src/ReactiveUI.Fody.Tests/API/ApiApprovalTests.ReactiveUI_Fody.approved.txt
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,31 @@ | ||
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.AndroidSupport")] | ||
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Tests")] | ||
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Winforms")] | ||
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Wpf")] | ||
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.XamForms")] | ||
[assembly: System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6.1", FrameworkDisplayName=".NET Framework 4.6.1")] | ||
namespace ReactiveUI.Fody.Helpers | ||
{ | ||
[System.AttributeUsageAttribute(System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.All)] | ||
public class ObservableAsPropertyAttribute : System.Attribute | ||
{ | ||
public ObservableAsPropertyAttribute() { } | ||
} | ||
public class static ObservableAsPropertyExtensions | ||
{ | ||
public static ReactiveUI.ObservableAsPropertyHelper<TRet> ToPropertyEx<TObj, TRet>(this System.IObservable<TRet> @this, TObj source, System.Linq.Expressions.Expression<System.Func<TObj, TRet>> property, TRet initialValue = null, bool deferSubscription = False, System.Reactive.Concurrency.IScheduler scheduler = null) | ||
where TObj : ReactiveUI.ReactiveObject { } | ||
} | ||
[System.AttributeUsageAttribute(System.AttributeTargets.Property | System.AttributeTargets.All)] | ||
public class ReactiveAttribute : System.Attribute | ||
{ | ||
public ReactiveAttribute() { } | ||
} | ||
[System.AttributeUsageAttribute(System.AttributeTargets.Property | System.AttributeTargets.All)] | ||
public class ReactiveDependencyAttribute : System.Attribute | ||
{ | ||
public ReactiveDependencyAttribute(string targetName) { } | ||
public string Target { get; } | ||
public string TargetProperty { 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,41 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MS-PL license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq; | ||
using ApprovalTests; | ||
using ApprovalTests.Reporters; | ||
using PublicApiGenerator; | ||
using ReactiveUI.Fody.Helpers; | ||
using Xunit; | ||
|
||
namespace ReactiveUI.Fody.Tests.API | ||
{ | ||
[ExcludeFromCodeCoverage] | ||
[UseReporter(typeof(DiffReporter))] | ||
public class ApiApprovalTests | ||
{ | ||
|
||
[Fact] | ||
public void ReactiveUI_Fody() | ||
{ | ||
var publicApi = Filter(ApiGenerator.GeneratePublicApi(typeof(ReactiveAttribute).Assembly)); | ||
Approvals.Verify(publicApi); | ||
} | ||
|
||
private static string Filter(string text) | ||
{ | ||
return string.Join(Environment.NewLine, text.Split(new[] | ||
{ | ||
Environment.NewLine | ||
}, StringSplitOptions.RemoveEmptyEntries) | ||
.Where(l => !l.StartsWith("[assembly: AssemblyVersion(")) | ||
.Where(l => !l.StartsWith("[assembly: AssemblyFileVersion(")) | ||
.Where(l => !l.StartsWith("[assembly: AssemblyInformationalVersion(")) | ||
.Where(l => !string.IsNullOrWhiteSpace(l)) | ||
); | ||
} | ||
} | ||
} |
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,10 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- | ||
Licensed to the .NET Foundation under one or more agreements. | ||
The .NET Foundation licenses this file to you under the MS-PL license. | ||
See the LICENSE file in the project root for more information. | ||
--> | ||
|
||
<Weavers> | ||
<ReactiveUI /> | ||
</Weavers> |
Oops, something went wrong.