|
| 1 | +# DendroDocs.Shared |
| 2 | + |
| 3 | +**DendroDocs.Shared** is a shared library used across multiple components of the DendroDocs ecosystem. |
| 4 | +It provides common utilities, abstractions, and extensions that are essential for the functionality of tools like [DendroDocs.Tool](https://github.com/dendrodocs/dotnet-tool) and other .NET-based projects using DendroDocs. |
| 5 | + |
| 6 | +## Features |
| 7 | + |
| 8 | +- **Data Models**: Comprehensive data models for representing .NET code structure including types, methods, properties, fields, and documentation comments |
| 9 | +- **Code Analysis**: Tools for parsing and representing .NET code elements with support for modifiers, attributes, and inheritance |
| 10 | +- **JSON Serialization**: Optimized JSON serialization utilities with custom converters for efficient data exchange |
| 11 | +- **String Extensions**: Helper methods for namespace and class name manipulation |
| 12 | +- **Statement Representations**: Models for control flow statements like if/else, switch, and foreach |
| 13 | +- **Documentation Parsing**: XML documentation comment parsing with support for all standard tags |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +To use **DendroDocs.Shared** in your project, install it as a NuGet package: |
| 18 | + |
| 19 | +```shell |
| 20 | +dotnet add package DendroDocs.Shared |
| 21 | +``` |
| 22 | + |
| 23 | +## Example usage |
| 24 | + |
| 25 | +```csharp |
| 26 | +using DendroDocs; |
| 27 | +using DendroDocs.Extensions; |
| 28 | +using DendroDocs.Json; |
| 29 | +using Newtonsoft.Json; |
| 30 | + |
| 31 | +// Working with type descriptions |
| 32 | +var types = new List<TypeDescription>(); |
| 33 | + |
| 34 | +// more code |
| 35 | +
|
| 36 | +var result = JsonConvert.SerializeObject(types.OrderBy(t => t.FullName), serializerSettings); |
| 37 | +``` |
| 38 | + |
| 39 | +## Library Components |
| 40 | + |
| 41 | +### Data Models (`DendroDocs` namespace) |
| 42 | + |
| 43 | +The library provides comprehensive data models for representing .NET code structure: |
| 44 | + |
| 45 | +- **`TypeDescription`**: Represents classes, interfaces, structs, enums, and delegates with their members |
| 46 | +- **`MethodDescription`**: Represents methods with parameters, return types, and method body statements |
| 47 | +- **`PropertyDescription`**: Represents properties with getters and setters |
| 48 | +- **`FieldDescription`**: Represents fields and constants |
| 49 | +- **`ConstructorDescription`**: Represents class constructors |
| 50 | +- **`EventDescription`**: Represents events and event handlers |
| 51 | +- **`AttributeDescription`**: Represents attributes applied to code elements |
| 52 | +- **`DocumentationCommentsDescription`**: Represents parsed XML documentation comments |
| 53 | + |
| 54 | +### String Extensions (`DendroDocs.Extensions` namespace) |
| 55 | + |
| 56 | +Utility methods for working with fully qualified type names: |
| 57 | + |
| 58 | +- **`ClassName()`**: Extracts the class name from a fully qualified name |
| 59 | +- **`Namespace()`**: Extracts the namespace from a fully qualified name |
| 60 | +- **`NamespaceParts()`**: Splits a namespace into its component parts |
| 61 | + |
| 62 | +### JSON Utilities (`DendroDocs.Json` namespace) |
| 63 | + |
| 64 | +Optimized JSON serialization for DendroDocs data models: |
| 65 | + |
| 66 | +- **`JsonDefaults`**: Provides pre-configured settings for both Newtonsoft.Json and System.Text.Json |
| 67 | +- **`SkipEmptyCollectionsContractResolver`**: Custom contract resolver to optimize JSON output |
| 68 | +- **`ConcreteTypeConverter`**: Handles polymorphic type serialization |
| 69 | + |
| 70 | +### Statement Models (`DendroDocs` namespace) |
| 71 | + |
| 72 | +Represents control flow and code statements: |
| 73 | + |
| 74 | +- **`Statement`**: Base class for all statement types |
| 75 | +- **`If`** / **`IfElseSection`**: Conditional statements |
| 76 | +- **`Switch`** / **`SwitchSection`**: Switch statements |
| 77 | +- **`ForEach`**: Iteration statements |
| 78 | +- **`InvocationDescription`**: Method and property invocations |
| 79 | +- **`AssignmentDescription`**: Variable assignments |
| 80 | +- **`ReturnDescription`**: Return statements |
| 81 | + |
| 82 | +## The DendroDocs Ecosystem |
| 83 | + |
| 84 | +**DendroDocs.Shared** is a crucial part of the broader DendroDocs ecosystem. |
| 85 | +Explore [DendroDocs](https://github.com/dendrodocs) to find more tools, libraries, and documentation resources that help you bridge the gap between your code and its documentation. |
| 86 | + |
| 87 | +## Contributing |
| 88 | + |
| 89 | +Contributions are welcome! Please feel free to create [issues](https://github.com/dendrodocs/dotnet-shared-lib/issues) or [pull requests](https://github.com/dendrodocs/dotnet-shared-lib/pulls). |
| 90 | + |
| 91 | +## License |
| 92 | + |
| 93 | +This project is licensed under the MIT License. |
0 commit comments