-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
1,047 additions
and
131 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,83 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier> | ||
<PackageId>NWN.Anvil</PackageId> | ||
<Authors>NWN.NET</Authors> | ||
<Description> | ||
Anvil is a C# framework for building behaviours and adding new functionalty to Neverwinter Nights: Enhanced Edition. The library allows server owners and builders to create simple behaviours, while giving plugin developers the option to implement complex systems or modify existing hardcoded rules. | ||
API Reference/Documentation - https://nwn-dotnet.github.io/Anvil/ | ||
GitHub, Issues and Discussions - https://github.com/nwn-dotnet/Anvil | ||
Discord, Latest News, Help and Support - https://discord.gg/gKt495UBgS | ||
</Description> | ||
<!-- https://github.com/NuGet/Home/issues/10791 --> | ||
<!-- <PackageReadmeFile>README.md</PackageReadmeFile> --> | ||
<PackageTags>Neverwinter Nights;NWN;</PackageTags> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> | ||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<EnableDynamicLoading>true</EnableDynamicLoading> | ||
<IncludeSymbols>true</IncludeSymbols> | ||
<DebugSymbols>true</DebugSymbols> | ||
<SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
<RepositoryUrl>https://github.com/nwn-dotnet/Anvil</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<EmbedUntrackedSources>true</EmbedUntrackedSources> | ||
<PublishRepositoryUrl>true</PublishRepositoryUrl> | ||
<NoWarn>1591</NoWarn> | ||
<RootNamespace /> | ||
<LangVersion>9.0</LangVersion> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<Configurations>Debug;Release;Samples</Configurations> | ||
<Platforms>AnyCPU</Platforms> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="LightInject" Version="6.4.0" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | ||
<PackageReference Include="NLog" Version="4.7.11" /> | ||
<PackageReference Include="NWN.Core" Version="8193.33.1" PrivateAssets="compile" /> | ||
<PackageReference Include="NWN.Native" Version="8193.33.0" PrivateAssets="compile" /> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="README.md" Pack="true" PackagePath="/" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition=" '$(Configuration)' != 'Samples'"> | ||
<None Remove="docs\**" /> | ||
<EmbeddedResource Remove="docs\**" /> | ||
<Compile Remove="docs\**" /> | ||
</ItemGroup> | ||
|
||
<Target Name="CreatePluginsFolder" AfterTargets="Build"> | ||
<MakeDir Directories="$(OutputPath)\Plugins" Condition="!Exists('$(OutputPath)\Plugins')" /> | ||
</Target> | ||
|
||
<Target Name="ZipOutputPath" AfterTargets="CreatePluginsFolder"> | ||
<ZipDirectory Overwrite="true" SourceDirectory="$(OutputPath)" DestinationFile="$(OutputPath)\..\$(MSBuildProjectName).zip" /> | ||
</Target> | ||
<!--Build--> | ||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
<LangVersion>9.0</LangVersion> | ||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier> | ||
|
||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> | ||
|
||
<ProduceReferenceAssembly>false</ProduceReferenceAssembly> | ||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
<EnableDynamicLoading>true</EnableDynamicLoading> | ||
|
||
<NoWarn>1591</NoWarn> | ||
|
||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<Configurations>Debug;Release;Samples</Configurations> | ||
<Platforms>AnyCPU</Platforms> | ||
|
||
<RootNamespace/> | ||
</PropertyGroup> | ||
|
||
<!--Package--> | ||
<PropertyGroup> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
|
||
<PackageId>$(AssemblyName)</PackageId> | ||
<Authors>NWN.NET</Authors> | ||
|
||
<RepositoryUrl>https://github.com/nwn-dotnet/Anvil</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
|
||
<Description> | ||
Anvil is a C# framework for building behaviours and adding new functionalty to Neverwinter Nights: Enhanced Edition. The library allows server owners and builders to create simple behaviours, while giving plugin developers the option to implement complex systems or modify existing hardcoded rules. | ||
API Reference/Documentation - https://nwn-dotnet.github.io/Anvil/ | ||
GitHub, Issues and Discussions - https://github.com/nwn-dotnet/Anvil | ||
Discord, Latest News, Help and Support - https://discord.gg/gKt495UBgS | ||
</Description> | ||
|
||
<!-- https://github.com/NuGet/Home/issues/10791 --> | ||
<!-- <PackageReadmeFile>README.md</PackageReadmeFile> --> | ||
<PackageTags>Neverwinter Nights;NWN;</PackageTags> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
</PropertyGroup> | ||
|
||
<!--Debug/Source Link--> | ||
<PropertyGroup> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<EmbedUntrackedSources>true</EmbedUntrackedSources> | ||
<PublishRepositoryUrl>true</PublishRepositoryUrl> | ||
<IncludeSymbols>true</IncludeSymbols> | ||
<DebugSymbols>true</DebugSymbols> | ||
<SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="LightInject" Version="6.4.0"/> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1"/> | ||
<PackageReference Include="NLog" Version="4.7.12"/> | ||
<PackageReference Include="NWN.Core" Version="8193.33.3" PrivateAssets="compile"/> | ||
<PackageReference Include="NWN.Native" Version="8193.33.2" PrivateAssets="compile"/> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="README.md" Pack="true" PackagePath="/"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition=" '$(Configuration)' != 'Samples'"> | ||
<None Remove="docs\**"/> | ||
<EmbeddedResource Remove="docs\**"/> | ||
<Compile Remove="docs\**"/> | ||
</ItemGroup> | ||
|
||
<Target Name="CreatePluginsFolder" AfterTargets="Build"> | ||
<MakeDir Directories="$(OutputPath)\Plugins" Condition="!Exists('$(OutputPath)\Plugins')"/> | ||
</Target> | ||
|
||
<Target Name="ZipOutputPath" AfterTargets="CreatePluginsFolder"> | ||
<ZipDirectory Overwrite="true" SourceDirectory="$(OutputPath)" DestinationFile="$(OutputPath)\..\$(MSBuildProjectName).zip"/> | ||
</Target> | ||
</Project> |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,49 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Reflection; | ||
|
||
namespace Anvil.API | ||
{ | ||
internal static class ReflectionExtensions | ||
public static class ReflectionExtensions | ||
{ | ||
/// <summary> | ||
/// Gets all attributes of a specific type on the specified type. | ||
/// </summary> | ||
/// <param name="type">The type to get attributes from</param> | ||
/// <param name="inherit">true if attributes should be inherited from base types</param> | ||
/// <typeparam name="T">The type of attribute to get</typeparam> | ||
/// <returns>An array of attributes applied to this type, or an empty array if no attributes are found.</returns> | ||
public static T[] GetCustomAttributes<T>(this Type type, bool inherit = true) where T : Attribute | ||
{ | ||
return (T[])type.GetCustomAttributes(typeof(T), inherit); | ||
} | ||
|
||
/// <summary> | ||
/// Gets all attributes of a specific type on the specified member. | ||
/// </summary> | ||
/// <param name="member">The member to get attributes from</param> | ||
/// <param name="inherit">true if attributes should be inherited from base types</param> | ||
/// <typeparam name="T">The type of attribute to get</typeparam> | ||
/// <returns>An array of attributes applied to this member, or an empty array if no attributes are found.</returns> | ||
public static T[] GetCustomAttributes<T>(this MemberInfo member, bool inherit = true) where T : Attribute | ||
{ | ||
return (T[])member.GetCustomAttributes(typeof(T), inherit); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the full name of the specified type member. | ||
/// </summary> | ||
/// <param name="member">The member to get the name of.</param> | ||
/// <returns>The full name of the member, prefixed with the namespace and enclosing type (if valid). If the member is not declared in a type, returns the member name.</returns> | ||
public static string GetFullName(this MemberInfo member) | ||
{ | ||
return member.DeclaringType != null ? $"{member.DeclaringType.FullName}.{member.Name}" : member.Name; | ||
} | ||
|
||
public static T SafeGetCustomAttribute<T>(this MemberInfo memberInfo, bool inherit = true) | ||
{ | ||
// GetCustomAttribute(Type) or GetCustomAttribute<T>() will throw an exception on types with missing assembly references, as they navigate into the type. | ||
return memberInfo.GetCustomAttributes(inherit).OfType<T>().FirstOrDefault(); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.