Added support for .NET Standard 1.1 and 1.2
This commit is contained in:
@@ -28,8 +28,8 @@ namespace Discord.Commands
|
||||
public static Dictionary<Type, ModuleInfo> Build(CommandService service, params TypeInfo[] validTypes) => Build(validTypes, service);
|
||||
public static Dictionary<Type, ModuleInfo> Build(IEnumerable<TypeInfo> validTypes, CommandService service)
|
||||
{
|
||||
if (!validTypes.Any())
|
||||
throw new InvalidOperationException("Could not find any valid modules from the given selection");
|
||||
/*if (!validTypes.Any())
|
||||
throw new InvalidOperationException("Could not find any valid modules from the given selection");*/
|
||||
|
||||
var topLevelGroups = validTypes.Where(x => x.DeclaringType == null);
|
||||
var subGroups = validTypes.Intersect(topLevelGroups);
|
||||
@@ -65,7 +65,8 @@ namespace Discord.Commands
|
||||
if (builtTypes.Contains(typeInfo))
|
||||
continue;
|
||||
|
||||
builder.AddModule((module) => {
|
||||
builder.AddModule((module) =>
|
||||
{
|
||||
BuildModule(module, typeInfo, service);
|
||||
BuildSubTypes(module, typeInfo.DeclaredNestedTypes, builtTypes, service);
|
||||
});
|
||||
@@ -106,7 +107,8 @@ namespace Discord.Commands
|
||||
|
||||
foreach (var method in validCommands)
|
||||
{
|
||||
builder.AddCommand((command) => {
|
||||
builder.AddCommand((command) =>
|
||||
{
|
||||
BuildCommand(command, typeInfo, method, service);
|
||||
});
|
||||
}
|
||||
@@ -147,21 +149,24 @@ namespace Discord.Commands
|
||||
int pos = 0, count = parameters.Length;
|
||||
foreach (var paramInfo in parameters)
|
||||
{
|
||||
builder.AddParameter((parameter) => {
|
||||
builder.AddParameter((parameter) =>
|
||||
{
|
||||
BuildParameter(parameter, paramInfo, pos++, count, service);
|
||||
});
|
||||
}
|
||||
|
||||
var createInstance = ReflectionUtils.CreateBuilder<ModuleBase>(typeInfo, service);
|
||||
|
||||
builder.Callback = (ctx, args, map) => {
|
||||
builder.Callback = (ctx, args, map) =>
|
||||
{
|
||||
var instance = createInstance(map);
|
||||
instance.Context = ctx;
|
||||
try
|
||||
{
|
||||
return method.Invoke(instance, args) as Task ?? Task.CompletedTask;
|
||||
return method.Invoke(instance, args) as Task ?? Task.Delay(0);
|
||||
}
|
||||
finally{
|
||||
finally
|
||||
{
|
||||
(instance as IDisposable)?.Dispose();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,41 +1,25 @@
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Description>A Discord.Net extension adding support for bot commands.</Description>
|
||||
<VersionPrefix>1.0.0-beta2</VersionPrefix>
|
||||
<TargetFramework>netstandard1.3</TargetFramework>
|
||||
<TargetFrameworks>netstandard1.1;netstandard1.3</TargetFrameworks>
|
||||
<AssemblyName>Discord.Net.Commands</AssemblyName>
|
||||
<PackageTags>discord;discordapp</PackageTags>
|
||||
<PackageProjectUrl>https://github.com/RogueException/Discord.Net</PackageProjectUrl>
|
||||
<PackageLicenseUrl>http://opensource.org/licenses/MIT</PackageLicenseUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>git://github.com/RogueException/Discord.Net</RepositoryUrl>
|
||||
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netstandard1.3' ">$(PackageTargetFallback);dotnet5.4;dnxcore50;portable-net45+win8</PackageTargetFallback>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="**\*.cs" />
|
||||
<EmbeddedResource Include="**\*.resx" />
|
||||
<EmbeddedResource Include="compiler\resources\**\*" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Sdk">
|
||||
<Version>1.0.0-alpha-20161104-2</Version>
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<PropertyGroup Label="Configuration">
|
||||
<SignAssembly>False</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
|
||||
<NoWarn>$(NoWarn);CS1573;CS1591</NoWarn>
|
||||
<WarningsAsErrors>true</WarningsAsErrors>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -32,12 +32,7 @@
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"netstandard1.3": {
|
||||
"imports": [
|
||||
"dotnet5.4",
|
||||
"dnxcore50",
|
||||
"portable-net45+win8"
|
||||
]
|
||||
}
|
||||
"netstandard1.1": {},
|
||||
"netstandard1.3": {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user