Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions Discord.Net.sln
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{BB59
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Discord.Net.BuildOverrides", "experiment\Discord.Net.BuildOverrides\Discord.Net.BuildOverrides.csproj", "{115F4921-B44D-4F69-996B-69796959C99D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ComponentDesigner", "ComponentDesigner", "{3752F226-625C-4564-8A19-B6E9F2329D1E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Discord.Net.ComponentDesigner", "src\Discord.Net.ComponentDesigner\Discord.Net.ComponentDesigner.csproj", "{11317A05-C2AF-4F5D-829F-129046C8E326}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Discord.Net.ComponentDesigner.Generator", "src\Discord.Net.ComponentDesigner.Generator\Discord.Net.ComponentDesigner.Generator.csproj", "{ACBDEE4C-FD57-4A47-B58B-6E10872D0464}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Discord.Net.ComponentDesigner.Parser", "src\Discord.Net.ComponentDesigner.Parser\Discord.Net.ComponentDesigner.Parser.csproj", "{F08906A4-7F99-47D9-B43A-905F631F81F8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Discord.Net.ComponentDesigner.LanguageServer", "src\Discord.Net.ComponentDesigner.LanguageServer\Discord.Net.ComponentDesigner.LanguageServer.csproj", "{3FD59032-5BA1-418F-88D3-EC385A63E6F2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -244,6 +254,54 @@ Global
{115F4921-B44D-4F69-996B-69796959C99D}.Release|x64.Build.0 = Release|Any CPU
{115F4921-B44D-4F69-996B-69796959C99D}.Release|x86.ActiveCfg = Release|Any CPU
{115F4921-B44D-4F69-996B-69796959C99D}.Release|x86.Build.0 = Release|Any CPU
{11317A05-C2AF-4F5D-829F-129046C8E326}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11317A05-C2AF-4F5D-829F-129046C8E326}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11317A05-C2AF-4F5D-829F-129046C8E326}.Debug|x64.ActiveCfg = Debug|Any CPU
{11317A05-C2AF-4F5D-829F-129046C8E326}.Debug|x64.Build.0 = Debug|Any CPU
{11317A05-C2AF-4F5D-829F-129046C8E326}.Debug|x86.ActiveCfg = Debug|Any CPU
{11317A05-C2AF-4F5D-829F-129046C8E326}.Debug|x86.Build.0 = Debug|Any CPU
{11317A05-C2AF-4F5D-829F-129046C8E326}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11317A05-C2AF-4F5D-829F-129046C8E326}.Release|Any CPU.Build.0 = Release|Any CPU
{11317A05-C2AF-4F5D-829F-129046C8E326}.Release|x64.ActiveCfg = Release|Any CPU
{11317A05-C2AF-4F5D-829F-129046C8E326}.Release|x64.Build.0 = Release|Any CPU
{11317A05-C2AF-4F5D-829F-129046C8E326}.Release|x86.ActiveCfg = Release|Any CPU
{11317A05-C2AF-4F5D-829F-129046C8E326}.Release|x86.Build.0 = Release|Any CPU
{ACBDEE4C-FD57-4A47-B58B-6E10872D0464}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ACBDEE4C-FD57-4A47-B58B-6E10872D0464}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ACBDEE4C-FD57-4A47-B58B-6E10872D0464}.Debug|x64.ActiveCfg = Debug|Any CPU
{ACBDEE4C-FD57-4A47-B58B-6E10872D0464}.Debug|x64.Build.0 = Debug|Any CPU
{ACBDEE4C-FD57-4A47-B58B-6E10872D0464}.Debug|x86.ActiveCfg = Debug|Any CPU
{ACBDEE4C-FD57-4A47-B58B-6E10872D0464}.Debug|x86.Build.0 = Debug|Any CPU
{ACBDEE4C-FD57-4A47-B58B-6E10872D0464}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ACBDEE4C-FD57-4A47-B58B-6E10872D0464}.Release|Any CPU.Build.0 = Release|Any CPU
{ACBDEE4C-FD57-4A47-B58B-6E10872D0464}.Release|x64.ActiveCfg = Release|Any CPU
{ACBDEE4C-FD57-4A47-B58B-6E10872D0464}.Release|x64.Build.0 = Release|Any CPU
{ACBDEE4C-FD57-4A47-B58B-6E10872D0464}.Release|x86.ActiveCfg = Release|Any CPU
{ACBDEE4C-FD57-4A47-B58B-6E10872D0464}.Release|x86.Build.0 = Release|Any CPU
{F08906A4-7F99-47D9-B43A-905F631F81F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F08906A4-7F99-47D9-B43A-905F631F81F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F08906A4-7F99-47D9-B43A-905F631F81F8}.Debug|x64.ActiveCfg = Debug|Any CPU
{F08906A4-7F99-47D9-B43A-905F631F81F8}.Debug|x64.Build.0 = Debug|Any CPU
{F08906A4-7F99-47D9-B43A-905F631F81F8}.Debug|x86.ActiveCfg = Debug|Any CPU
{F08906A4-7F99-47D9-B43A-905F631F81F8}.Debug|x86.Build.0 = Debug|Any CPU
{F08906A4-7F99-47D9-B43A-905F631F81F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F08906A4-7F99-47D9-B43A-905F631F81F8}.Release|Any CPU.Build.0 = Release|Any CPU
{F08906A4-7F99-47D9-B43A-905F631F81F8}.Release|x64.ActiveCfg = Release|Any CPU
{F08906A4-7F99-47D9-B43A-905F631F81F8}.Release|x64.Build.0 = Release|Any CPU
{F08906A4-7F99-47D9-B43A-905F631F81F8}.Release|x86.ActiveCfg = Release|Any CPU
{F08906A4-7F99-47D9-B43A-905F631F81F8}.Release|x86.Build.0 = Release|Any CPU
{3FD59032-5BA1-418F-88D3-EC385A63E6F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3FD59032-5BA1-418F-88D3-EC385A63E6F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FD59032-5BA1-418F-88D3-EC385A63E6F2}.Debug|x64.ActiveCfg = Debug|Any CPU
{3FD59032-5BA1-418F-88D3-EC385A63E6F2}.Debug|x64.Build.0 = Debug|Any CPU
{3FD59032-5BA1-418F-88D3-EC385A63E6F2}.Debug|x86.ActiveCfg = Debug|Any CPU
{3FD59032-5BA1-418F-88D3-EC385A63E6F2}.Debug|x86.Build.0 = Debug|Any CPU
{3FD59032-5BA1-418F-88D3-EC385A63E6F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FD59032-5BA1-418F-88D3-EC385A63E6F2}.Release|Any CPU.Build.0 = Release|Any CPU
{3FD59032-5BA1-418F-88D3-EC385A63E6F2}.Release|x64.ActiveCfg = Release|Any CPU
{3FD59032-5BA1-418F-88D3-EC385A63E6F2}.Release|x64.Build.0 = Release|Any CPU
{3FD59032-5BA1-418F-88D3-EC385A63E6F2}.Release|x86.ActiveCfg = Release|Any CPU
{3FD59032-5BA1-418F-88D3-EC385A63E6F2}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -264,6 +322,10 @@ Global
{B61AAE66-15CC-40E4-873A-C23E697C3411} = {BB59D5B5-E7B0-4BF4-8F82-D14431B2799B}
{4A03840B-9EBE-47E3-89AB-E0914DF21AFB} = {BB59D5B5-E7B0-4BF4-8F82-D14431B2799B}
{115F4921-B44D-4F69-996B-69796959C99D} = {CC3D4B1C-9DE0-448B-8AE7-F3F1F3EC5C3A}
{11317A05-C2AF-4F5D-829F-129046C8E326} = {3752F226-625C-4564-8A19-B6E9F2329D1E}
{ACBDEE4C-FD57-4A47-B58B-6E10872D0464} = {3752F226-625C-4564-8A19-B6E9F2329D1E}
{F08906A4-7F99-47D9-B43A-905F631F81F8} = {3752F226-625C-4564-8A19-B6E9F2329D1E}
{3FD59032-5BA1-418F-88D3-EC385A63E6F2} = {3752F226-625C-4564-8A19-B6E9F2329D1E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D2404771-EEC8-45F2-9D71-F3373F6C1495}
Expand Down
8 changes: 4 additions & 4 deletions Discord.Net.targets
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
<NoWarn>$(NoWarn);CS1573;CS1591</NoWarn>
<WarningsAsErrors>true</WarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
<ItemGroup>
<None Include="../../docs/marketing/logo/PackageLogo.png" Pack="true" PackagePath=""/>
<None Include="../../NUGET_README.md" Pack="true" PackagePath=""/>
<None Include="../../docs/marketing/logo/PackageLogo.png" Pack="true" PackagePath="" />
<None Include="../../NUGET_README.md" Pack="true" PackagePath="" />
</ItemGroup>
</Project>
</Project>
43 changes: 43 additions & 0 deletions src/Discord.Net.ComponentDesigner.Generator/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace Discord.CX;

public static class Constants
{
public const string COMPONENT_DESIGNER_QUALIFIED_NAME = "Discord.DesignerInterpolationHandler";
public const string INTERPOLATION_DESIGNER_QUALIFIED_NAME = "Discord.DesignerInterpolationHandler";

public const int PLACEHOLDER_MAX_LENGTH = 150;

public const int BUTTON_MAX_LABEL_LENGTH = 80;
public const int CUSTOM_ID_MAX_LENGTH = 100;
public const int BUTTON_URL_MAX_LENGTH = 512;

public const int MAX_ACTION_ROW_COMPONENTS = 5;

public const int SELECT_MIN_VALUES = 0;
public const int SELECT_MAX_VALUES = 25;

public const int MAX_MEDIA_ITEMS = 25;
public const int MAX_MEDIA_ITEM_DESCRIPTION_LENGTH = 1024;

public const int MAX_SECTION_CHILDREN = 3;

public const int STRING_SELECT_OPTION_LABEL_MAX_LENGTH = 100;
public const int STRING_SELECT_OPTION_VALUE_MAX_LENGTH = 100;
public const int STRING_SELECT_OPTION_DESCRIPTION_MAX_LENGTH = 100;

public const int TEXT_INPUT_LABEL_MAX_LENGTH = 45;

public const int TEXT_INPUT_MIN_LENGTH_MIN_VALUE = 0;
public const int TEXT_INPUT_MIN_LENGTH_MAX_VALUE = 4000;

public const int TEXT_INPUT_MAX_LENGTH_MIN_VALUE = 1;
public const int TEXT_INPUT_MAX_LENGTH_MAX_VALUE = 4000;

public const int TEXT_INPUT_VALUE_MAX_LENGTH = 4000;
public const int TEXT_INPUT_PLACEHOLDER_MAX_LENGTH = 100;

public const int THUMBNAIL_DESCRIPTION_MAX_LENGTH = 1024;



}
249 changes: 249 additions & 0 deletions src/Discord.Net.ComponentDesigner.Generator/Diagnostics.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
using Microsoft.CodeAnalysis;

namespace Discord.CX;

public static partial class Diagnostics
{
public static readonly DiagnosticDescriptor ParseError = new(
"DCP001",
"CX Parsing error",
"{0}",
"Component Parser (CX)",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor InvalidEnumVariant = new(
"DC0001",
"Invalid enum variant",
"'{0}' is not a valid variant of '{1}'; valid values are '{2}'",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor TypeMismatch = new(
"DC0002",
"Type mismatch",
"'{0}' is not of expected type '{1}'",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor OutOfRange = new(
"DC0003",
"Type mismatch",
"'{0}' must be {1} in length",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor UnknownComponent = new(
"DC0004",
"Unknown component",
"'{0}' is not a known component",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor ButtonCustomIdUrlConflict = new(
"DC0005",
"Invalid button",
"Buttons cannot contain both a 'url' and a 'customid'",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor ButtonCustomIdOrUrlMissing = new(
"DC0006",
"Invalid button",
"A button must specify either a 'customId' or a 'url'",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor LinkButtonUrlMissing = new(
"DC0007",
"Invalid button",
"A 'link' button must specify 'url'",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor PremiumButtonSkuMissing = new(
"DC0008",
"Invalid button",
"A 'premium' button must specify 'skuId'",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor PremiumButtonPropertyNotAllowed = new(
"DC0009",
"Invalid button",
"A 'premium' button cannot specify '{0}'",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor ButtonLabelDuplicate = new(
"DC0010",
"Duplicate label definition",
"A button cannot specify both a body and a 'label'",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor EmptyActionRow = new(
"DC0011",
"Empty Action Row",
"An action row must contain at least one child",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor MissingRequiredProperty = new(
"DC0012",
"Missing Property",
"'{0}' requires the property '{1}' to be specified",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor UnknownProperty = new(
"DC0013",
"Unknown Property",
"'{0}' is not a known property of '{1}'",
"Components",
DiagnosticSeverity.Warning,
true
);

public static readonly DiagnosticDescriptor EmptyAccessory = new(
"DC0014",
"Empty Accessory",
"An accessory must have 1 child",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor TooManyAccessoryChildren = new(
"DC0015",
"Too many accessory children",
"An accessory must have 1 child",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor EmptySection = new(
"DC0016",
"Section cannot be empty",
"A section must have an accessory and a child",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor InvalidAccessoryChild = new(
"DC0017",
"Invalid accessory child",
"'{0}' is not a valid accessory, only buttons and thumbnails are allowed",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor MissingAccessory = new(
"DC0018",
"Missing accessory",
"A section must contain an accessory",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor TooManyAccessories = new(
"DC0019",
"Too many accessories",
"A section can only contain one accessory",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor MissingSectionChild = new(
"DC0020",
"Missing section child",
"A section must contain at least 1 non-accessory component",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor TooManySectionChildren = new(
"DC0021",
"Too many section children",
"A section must contain at most 3 non-accessory components",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor InvalidSectionChildComponentType = new(
"DC0022",
"Invalid section child component type",
"'{0}' is not a valid child component of a section; only text displays are allowed",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor MissingSelectMenuType = new(
"DC0023",
"Missing select menu type",
"You must specify the type of the select menu, being one of 'string', 'user', 'role', 'channel', or 'mentionable'",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor InvalidSelectMenuType = new(
"DC0024",
"Invalid select menu type",
"Select menu type must be either 'string', 'user', 'role', 'channel', or 'mentionable'",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor SpecifiedInvalidSelectMenuType = new(
"DC0025",
"Invalid select menu type",
"'{0}' is not a valid elect menu type; must be either 'string', 'user', 'role', 'channel', or 'mentionable'",
"Components",
DiagnosticSeverity.Error,
true
);

public static readonly DiagnosticDescriptor ActionRowInvalidChild = new(
"DC0026",
"Invalid action row child component",
"An action row can only contain 1 select menu OR at most 5 buttons",
"Components",
DiagnosticSeverity.Error,
true
);
}
Loading
Loading