Skip to content

Commit

Permalink
Feature/use more fody helpers (#5)
Browse files Browse the repository at this point in the history
* refactory

* MoreFodyHelpers

* fix nuget

* revert

---------

Co-authored-by: jeremyli <[email protected]>
  • Loading branch information
huoshan12345 and jeremyliseismic authored Oct 19, 2023
1 parent 442ae95 commit e73d5e3
Show file tree
Hide file tree
Showing 59 changed files with 414 additions and 2,306 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
dotnet-version: |
6.0.x
7.0.x
Expand Down
3 changes: 2 additions & 1 deletion InterfaceBaseInvoke.sln
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{41D4FE14
ProjectSection(SolutionItems) = preProject
.github\workflows\build.yml = .github\workflows\build.yml
build\incre_ver.ps1 = build\incre_ver.ps1
NuGet.Config = NuGet.Config
build\pack.ps1 = build\pack.ps1
build\pkg.version = build\pkg.version
README.md = README.md
build\test_all.ps1 = build\test_all.ps1
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "example", "example", "{BBD57099-9025-40DB-9A1E-5094DE6736A9}"
Expand All @@ -42,6 +42,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{CFB3FFC9-C653-4830-A696-CE150BECC295}"
ProjectSection(SolutionItems) = preProject
src\Directory.Build.props = src\Directory.Build.props
src\MoreFodyHelpers.props = src\MoreFodyHelpers.props
EndProjectSection
EndProject
Global
Expand Down
1 change: 1 addition & 0 deletions NuGet.config → NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<!--<add key="local" value="D:\projects\MoreFodyHelpers\build" />-->
</packageSources>
</configuration>
2 changes: 1 addition & 1 deletion build/pkg.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.1
0.1.2
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\InterfaceBaseInvoke.Fody\InterfaceBaseInvoke.Fody.csproj" />
<ProjectReference Include="..\InterfaceBaseInvoke\InterfaceBaseInvoke.csproj" />
</ItemGroup>

Expand Down
95 changes: 47 additions & 48 deletions src/InterfaceBaseInvoke.Example/Program.cs
Original file line number Diff line number Diff line change
@@ -1,62 +1,61 @@
using System;

namespace InterfaceBaseInvoke.Example
namespace InterfaceBaseInvoke.Example;

public interface IService
{
public interface IService
{
int Property { get; }
void Method();
}
int Property { get; }
void Method();
}

public interface IService1 : IService
{
public const string Name = nameof(IService1) + "." + nameof(Method);
int IService.Property => 1;
void IService.Method() => Console.WriteLine(Name);
}
public interface IService1 : IService
{
public const string Name = nameof(IService1) + "." + nameof(Method);
int IService.Property => 1;
void IService.Method() => Console.WriteLine(Name);
}

public interface IService2 : IService
{
public const string Name = nameof(IService2) + "." + nameof(Method);
int IService.Property => 2;
void IService.Method() => Console.WriteLine(Name);
}
public interface IService2 : IService
{
public const string Name = nameof(IService2) + "." + nameof(Method);
int IService.Property => 2;
void IService.Method() => Console.WriteLine(Name);
}

public interface IService3
{
void Method<T>() => Console.WriteLine(typeof(T).Name);
}
public interface IService3
{
void Method<T>() => Console.WriteLine(typeof(T).Name);
}

public interface IService4<T>
{
void Method() => Console.WriteLine(typeof(T).Name);
}
public interface IService4<T>
{
void Method() => Console.WriteLine(typeof(T).Name);
}

public class Service : IService1, IService2, IService3, IService4<string>
{
public void Method() => throw new InvalidOperationException();
public int Property => throw new InvalidOperationException();

public class Service : IService1, IService2, IService3, IService4<string>
public void Invoke()
{
public void Method() => throw new InvalidOperationException();
public int Property => throw new InvalidOperationException();

public void Invoke()
{
Console.WriteLine("Start invoking...");
this.Base<IService1>().Method();
this.Base<IService2>().Method();
this.Base<IService3>().Method<int>();
this.Base<IService4<string>>().Method();
Console.WriteLine(this.Base<IService1>().Property);
Console.WriteLine(this.Base<IService2>().Property);
Console.WriteLine("End invoking.");
}
Console.WriteLine("Start invoking...");
this.Base<IService1>().Method();
this.Base<IService2>().Method();
this.Base<IService3>().Method<int>();
this.Base<IService4<string>>().Method();
Console.WriteLine(this.Base<IService1>().Property);
Console.WriteLine(this.Base<IService2>().Property);
Console.WriteLine("End invoking.");
}
}

internal class Program
internal class Program
{
private static void Main(string[] args)
{
private static void Main(string[] args)
{
var service = new Service();
service.Invoke();
Console.Read();
}
var service = new Service();
service.Invoke();
Console.Read();
}
}

This file was deleted.

Loading

0 comments on commit e73d5e3

Please sign in to comment.