Skip to content

Commit

Permalink
merged and updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianSauer committed Sep 1, 2024
2 parents 5b3e167 + 40c1f8e commit f30a718
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<EnableNETAnalyzers>True</EnableNETAnalyzers>
<AnalysisLevel>latest-Recommended</AnalysisLevel>
<Version>5.0.0</Version>
<Version>5.0.1</Version>
<PackageReadmeFile>README.md</PackageReadmeFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>1701;1702;NU5128</NoWarn>
Expand Down
11 changes: 3 additions & 8 deletions AutomaticInterface/AutomaticInterfaceExample/DemoClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public class DemoClass : IDemoClass // Generics, including constraints are allow

public string OnlyGet { get; } // included, get and set are copied to the interface when public

Check warning on line 23 in AutomaticInterface/AutomaticInterfaceExample/DemoClass.cs

View workflow job for this annotation

GitHub Actions / test

Non-nullable property 'OnlyGet' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 23 in AutomaticInterface/AutomaticInterfaceExample/DemoClass.cs

View workflow job for this annotation

GitHub Actions / publish

Non-nullable property 'OnlyGet' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

public string? NullableProperty { get; set; }
[IgnoreAutomaticInterface]
public string? AnotherGet { get; } // ignored with help of attribute

/// <summary>
/// Method Documentation will be copied
Expand All @@ -46,13 +47,7 @@ public string CMethod<T, T1, T2, T3, T4>(string? x, string y) // included
return "Ok";
}

[IgnoreAutomaticInterface]
public string IgnoreMethod(string x, string y) // // ignored because of attribute
{
return BMethod(x, y);
}

public Task<string?> ASync(string x, string y)
public Task<string> ASync(string x, string y)
{
return Task.FromResult("");
}
Expand Down
14 changes: 0 additions & 14 deletions AutomaticInterface/TestNuget/RemoveThisOnNextVersionAttribute.cs

This file was deleted.

2 changes: 1 addition & 1 deletion AutomaticInterface/TestNuget/TestNuget.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutomaticInterface" Version="2.0.0">
<PackageReference Include="AutomaticInterface" Version="4.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
40 changes: 29 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,29 @@ namespace AutomaticInterfaceExample
class DemoClass: IDemoClass // Your interface will get the Name I+classname, here IDemoclass.
// Generics, including constraints are allowed, too. E.g. MyClass<T> where T: class
{

/// <summary>
/// Property Documentation will be copied
/// </summary>
public string Hello { get; set; } // included, get and set are copied to the interface when public
public string Hello { get; set; } // included, get and set are copied to the interface when public
public string OnlyGet { get; } // included, get and set are copied to the interface when public
[IgnoreAutomaticInterface]
public string OnlyGet { get; } // ignored with help of attribute
[IgnoreAutomaticInterface]
public string? AnotherGet { get; } // ignored with help of attribute
/// <summary>
/// Method Documentation will be copied
/// </summary>
public string AMethod(string x, string y) // included
{
return BMethod(x,y);
return BMethod(x, y);
}

private string BMethod(string x, string y) // ignored because not public
{
return x + y;
}

public string CMethod<T, T1, T2, T3, T4>(string? x, string y) // included
where T : class
where T1 : struct
Expand All @@ -59,9 +58,14 @@ namespace AutomaticInterfaceExample
return "Ok";
}

public Task<string> ASync(string x, string y)
{
return Task.FromResult("");
}

public static string StaticProperty => "abc"; // static property, ignored
public static string StaticMethod() // static method, ignored
public static string StaticMethod() // static method, ignored
{
return "static" + DateTime.Now;
}
Expand Down Expand Up @@ -111,11 +115,20 @@ namespace AutomaticInterfaceExample
string AMethod(string x, string y);

/// <inheritdoc />
string CMethod<T, T1, T2, T3, T4>(string? x, string y) where T : class where T1 : struct where T3 : global::AutomaticInterfaceExample.DemoClass where T4 : IDemoClass;
string CMethod<T, T1, T2, T3, T4>(string? x, string y) where T : class where T1 : struct where T3 : DemoClass where T4 : IDemoClass;

/// <inheritdoc />
global::System.Threading.Tasks.Task<string> ASync(string x, string y);

/// <inheritdoc />
event global::System.EventHandler ShapeChanged;

/// <inheritdoc />
event global::System.EventHandler? ShapeChangedNullable;

/// <inheritdoc />
event global::System.EventHandler<string?> ShapeChangedNullable2;

}
}
#nullable restore
Expand All @@ -124,7 +137,7 @@ namespace AutomaticInterfaceExample
## How to use it?

1. Install the nuget: `dotnet add package AutomaticInterface`.
2. Add `using AutomaticInterface;` or (Pro-tip) add `global using AutomaticInterface;` to you GlobalUsings.
2. Add `using AutomaticInterface;` or (Pro-tip) add `global using AutomaticInterface;` to your GlobalUsings.
3. Tag your class with the `[GenerateAutomaticInterface]` attribute.
4. The Interface should now be available.

Expand Down Expand Up @@ -163,7 +176,7 @@ Please make sure that you run [CSharpier](https://csharpier.com/) on the code fo
- mohummedibrahim for code and idea
- simonmckenzie for PRs
- avtc for PR
- crwsolutions for PR
- crwsolutions for PRs
- FinnAngelo for PR

## Run tests
Expand All @@ -174,7 +187,12 @@ Should be simply a build and run Tests

### 5.0.0

- 4.0.0 changed how parameters where qualified - this PR changes it to using qualified names everywhere because 4.0.0 broke lots of stuff. Thanks for your contributions!
- Sync DemoClass and actual generated code with README. Thanks, @crwsolutions!
- Removed manual attribute in TestNuget project. Thanks, @crwsolutions!

### 5.0.0

- 4.0.0 changed how parameters where qualified - this PR changes it to using qualified names everywhere because 4.0.0 broke lots of stuff. Thanks for your contributions! Especially simonmckenzie for the hard work and realbart for bringing it up

### 4.1.0

Expand Down

0 comments on commit f30a718

Please sign in to comment.