Skip to content

Commit cab3fcb

Browse files
committed
Update README.md
1 parent 69ecc73 commit cab3fcb

File tree

1 file changed

+5
-102
lines changed

1 file changed

+5
-102
lines changed

README.md

Lines changed: 5 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -16,112 +16,15 @@ Latest development packages can be found on [MyGet](https://www.myget.org/galler
1616
The following packages are published as source NuGet packages, your application or library will not
1717
have a runtime dependency on them.
1818

19-
| Package | Description |
20-
|----------------------------------|-------------------------------------------------------------------------------|
21-
| `AppCoreNet.Attributes.Sources` | Provides poly fills for .NET attributes. |
22-
| `AppCoreNet.Diagnostics.Sources` | Provides static classes to ensure program contracts. |
23-
| `AppCoreNet.TypeHelpers.Sources` | Includes extensions for `Type` and `Assembly` and a fast activator for types. |
19+
| Package | Description |
20+
|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------|
21+
| [`AppCoreNet.Attributes.Sources`](src/AppCoreNet.Attributes.Sources/README.md) | Provides poly fills for .NET attributes. |
22+
| [`AppCoreNet.Diagnostics.Sources`](src/AppCoreNet.Diagnostics.Sources/README.md) | Provides static classes to ensure program contracts. |
23+
| [`AppCoreNet.TypeHelpers.Sources`](src/AppCoreNet.TypeHelpers.Sources/README.md) | Includes extensions for `Type` and `Assembly` and a fast activator for types. |
2424

2525
## Contributing
2626

2727
Contributions, whether you file an issue, fix some bug or implement a new feature, are highly appreciated. The whole user community
2828
will benefit from them.
2929

3030
Please refer to the [Contribution guide](CONTRIBUTING.md).
31-
32-
# Usage
33-
34-
## AppCoreNet.Attributes.Sources
35-
36-
This package includes sources for attributes which are defined in newer .NET versions (>= .NET Core 3.0) such as
37-
attributes required for nullable reference types, attributes required for the `required` keyword and others.
38-
39-
If you are using the `Polyfill` or `Nullable` package these attributes are automatically disabled. You can control the
40-
inclusion of these attributes with the following MSBuild properties:
41-
42-
- `AppCoreNetAttributesEnabled`
43-
Enables/disables all attributes.
44-
- `AppCoreNetNullableAttributesEnabled`
45-
Enables/disables the nullable attributes.
46-
- `AppCoreNetTrimmingAttributesEnabled`
47-
Enables/disables the trimming attributes.
48-
49-
50-
For example:
51-
52-
```msbuild
53-
<Project>
54-
<PropertyGroup>
55-
<AppCoreNetAttributesEnabled>false</AppCoreNetAttributesEnabled>
56-
</PropertyGroup>
57-
</Project>
58-
```
59-
60-
Will disable all attributes.
61-
62-
## AppCoreNet.Diagnostics.Sources
63-
64-
This package includes sources of static classes to ensure program contracts such as pre-conditions, post-conditions and
65-
invariants.
66-
67-
### Pre-conditions
68-
69-
Ensuring that some argument is not null:
70-
```csharp
71-
public void SomeMethod(object obj)
72-
{
73-
// this will throw 'ArgumentNullException' if 'obj' is null
74-
Ensure.Arg.NotNull(obj);
75-
}
76-
```
77-
78-
Ensuring that some string argument is not null or empty/only whitespace:
79-
```csharp
80-
public void SomeMethod(string str)
81-
{
82-
// this will throw 'ArgumentNullException' or 'ArgumentException' if 'str' is null or empty
83-
Ensure.Arg.NotEmpty(str);
84-
}
85-
```
86-
87-
Ensuring that some value argument is in range:
88-
```csharp
89-
public void SomeMethod(int val)
90-
{
91-
// this will throw 'ArgumentOutOfRangeException' if 'val' is < 0 || > 10
92-
Ensure.Arg.InRange(val, 0, 10);
93-
}
94-
```
95-
96-
Other pre-condition checks are available: `Ensure.Arg.NotNullButEmpty()`, `Ensure.Arg.MinLength()`, `Ensure.Arg.MaxLength()`, `Ensure.Arg.OfType()`.
97-
98-
Note that the package also supports annotations for ReSharper. Simply add the package `ReSharper.Annotations` to your
99-
project.
100-
101-
## AppCoreNet.TypeHelpers.Sources
102-
103-
Includes various extensions for the `Type` and `Assembly` classes to make your live easier when working
104-
with open generic types. Also provides a fast activator (factory) for dynamically instantiating types.
105-
106-
Getting friendly type name for display, supports generics:
107-
```csharp
108-
class MyType<T> { }
109-
typeof(MyType<>).GetDisplayName() // returns 'MyNamespace.MyType<T>'
110-
```
111-
112-
Creating an instance of a type:
113-
114-
```csharp
115-
// creates an instance of 'MyType' with default constructor
116-
TypeActivator.CreateInstance<MyType>()
117-
118-
// alternatively (if the Type is not known at compile time):
119-
TypeActivator.CreateInstance(typeof(MyType))
120-
```
121-
122-
Checking if some type implements generic type:
123-
124-
```csharp
125-
class StringList : List<string> { }
126-
typeof(StringList).IsClosedTypeOf(typeof(List<>))
127-
```

0 commit comments

Comments
 (0)