Skip to content

Commit cebe57c

Browse files
committed
Fixed Obsolete Description
1 parent b61b7d9 commit cebe57c

File tree

13 files changed

+63
-19
lines changed

13 files changed

+63
-19
lines changed

Linq2GraphQL.sln

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".items", ".items", "{7A8567FE-C13A-434E-AFA6-5A8F55F2C6B5}"
99
ProjectSection(SolutionItems) = preProject
1010
.gitignore = .gitignore
11+
Directory.Packages.props = Directory.Packages.props
1112
nuget.config = nuget.config
1213
README.md = README.md
1314
version.json = version.json
14-
Directory.Packages.props = Directory.Packages.props
1515
EndProjectSection
1616
EndProject
1717
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Linq2GraphQL.TestServer", "test\Linq2GraphQL.TestServer\Linq2GraphQL.TestServer.csproj", "{AD8291B6-5979-4C43-B785-EAD4FF93C564}"
@@ -54,6 +54,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
5454
README.md = README.md
5555
EndProjectSection
5656
EndProject
57+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartGG", "StartGG\StartGG.csproj", "{B59EEB8E-8B81-4470-9295-86DF27A769D2}"
58+
EndProject
5759
Global
5860
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5961
Debug|Any CPU = Debug|Any CPU
@@ -108,6 +110,10 @@ Global
108110
{3C66EF43-E66D-46DE-B2BB-434E7FC20487}.Debug|Any CPU.Build.0 = Debug|Any CPU
109111
{3C66EF43-E66D-46DE-B2BB-434E7FC20487}.Release|Any CPU.ActiveCfg = Release|Any CPU
110112
{3C66EF43-E66D-46DE-B2BB-434E7FC20487}.Release|Any CPU.Build.0 = Release|Any CPU
113+
{B59EEB8E-8B81-4470-9295-86DF27A769D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
114+
{B59EEB8E-8B81-4470-9295-86DF27A769D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
115+
{B59EEB8E-8B81-4470-9295-86DF27A769D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
116+
{B59EEB8E-8B81-4470-9295-86DF27A769D2}.Release|Any CPU.Build.0 = Release|Any CPU
111117
EndGlobalSection
112118
GlobalSection(SolutionProperties) = preSolution
113119
HideSolutionNode = FALSE
@@ -123,6 +129,7 @@ Global
123129
{C0E1A444-A834-4FC0-8436-38066EA8D37D} = {F646B02D-53FC-4C88-8941-2255A2F4DAF6}
124130
{A941BD4C-8B04-4273-AC0B-CF86D71D7E0B} = {884758A6-B667-4CA0-B186-AFB6331A24A5}
125131
{3C66EF43-E66D-46DE-B2BB-434E7FC20487} = {884758A6-B667-4CA0-B186-AFB6331A24A5}
132+
{B59EEB8E-8B81-4470-9295-86DF27A769D2} = {884758A6-B667-4CA0-B186-AFB6331A24A5}
126133
EndGlobalSection
127134
GlobalSection(ExtensibilityGlobals) = postSolution
128135
SolutionGuid = {01DC7AB7-9900-4FCA-BACB-7DAAE825E25E}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ Install/Update Tool:
6363
-s, --subscriptions Include subscriptions (Exprimental)
6464
-es --enum-strategy If AddUnknownOption all enums will have an additional Unknown option
6565
-nu --nullabel Nullable client [default: false]
66-
66+
-d --deprecated Include Deprecated as Obsolete
67+
6768
As an example:
6869

6970
Linq2GraphQL https://spacex-production.up.railway.app/ -c="SpaceXClient" -n="SpaceX" -o="Generated"

StartGG/Program.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace StartGG
2+
{
3+
internal class Program
4+
{
5+
static void Main(string[] args)
6+
{
7+
Console.WriteLine("Hello, World!");
8+
}
9+
}
10+
}

StartGG/StartGG.csproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<ProjectReference Include="..\src\Linq2GraphQL.Client\Linq2GraphQL.Client.csproj" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<Folder Include="Client\" />
16+
</ItemGroup>
17+
18+
</Project>

docs/Linq2GraphQL.Docs/Components/GenerateClient.razor.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ protected override void OnInitialized()
4444
ClientName = "GithubClient",
4545
Token = "[Your Token]"
4646
});
47+
demoOptions.Add(new GenerateOptions
48+
{
49+
Url = "https://api.start.gg/gql/alpha",
50+
Namespace = "StartGG.Client",
51+
ClientName = "StartGGClient",
52+
Token = "[Your Token]"
53+
});
4754

4855
//
4956

src/Linq2GraphQL.Generator/General.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,11 @@ query Into {
4747
enumValues {
4848
name
4949
description
50-
isDeprecated
51-
deprecationReason
5250
}
5351
5452
fields {
5553
name
5654
description
57-
isDeprecated
58-
deprecationReason
5955
type {
6056
...BaseType
6157
}
@@ -71,8 +67,6 @@ query Into {
7167
inputFields {
7268
name
7369
description
74-
isDeprecated
75-
deprecationReason
7670
type {
7771
...BaseType
7872
}

src/Linq2GraphQL.Generator/GraphQLSchema/Helpers.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ public static class Helpers
88
internal static string SummarySafe(string text)
99
{
1010
if (string.IsNullOrEmpty(text)) { return text; }
11-
1211
return Regex.Replace(text, @"\r\n?|\n", Environment.NewLine + "/// ");
12+
}
1313

14+
internal static string SafeDeprecationReason(string text)
15+
{
16+
if (string.IsNullOrEmpty(text)) { return text; }
17+
return text.Replace("\"", "'");
1418
}
1519

20+
1621
public static readonly Dictionary<string, (string Name, Type type)> TypeMapping =
1722
new(StringComparer.InvariantCultureIgnoreCase)
1823
{

src/Linq2GraphQL.Generator/GraphQLSchema/RootSchema.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ public class EnumValue
111111
public bool IsDeprecated { get; set; }
112112
public string DeprecationReason { get; set; }
113113

114+
public string SafeDeprecationReason => Helpers.SafeDeprecationReason(DeprecationReason);
115+
114116

115117
public string GetCSharpName()
116118
{
@@ -133,6 +135,8 @@ public class BaseField
133135
public bool IsDeprecated { get; set; }
134136
public string DeprecationReason { get; set; }
135137

138+
public string SafeDeprecationReason => Helpers.SafeDeprecationReason(DeprecationReason);
139+
136140
public bool HasDescription => !string.IsNullOrEmpty(Description);
137141

138142
public string SummaryDescription => Helpers.SummarySafe(Description);

src/Linq2GraphQL.Generator/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ private static async Task Main(string[] args)
2020
var authToken = new Option<string>(new[] { "--token", "-t" }, "Bearertoken for authentication");
2121
var includeSubscriptions = new Option<bool>(new[] { "--subscriptions", "-s" }, "Include subscriptions");
2222
var enumStrategy = new Option<string>(new[] { "--enum-strategy", "-es" }, "Enum strategy");
23-
2423
var nullable = new Option<bool>(new[] { "--nullable", "-nu" }, "Nullable client");
25-
2624
var includeDeprecated = new Option<bool>(new[] { "--deprecated", "-d" }, "Include Deprecated as Obsolete");
2725

2826
var rootCommand = new RootCommand("Generate GraphQL client")

src/Linq2GraphQL.Generator/Templates/Class/ClassTemplate.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public virtual string TransformText()
8686
this.Write(" [Obsolete(\"");
8787

8888
#line 21 "C:\Code\Github\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Class\ClassTemplate.tt"
89-
this.Write(this.ToStringHelper.ToStringWithCulture(field.DeprecationReason));
89+
this.Write(this.ToStringHelper.ToStringWithCulture(field.SafeDeprecationReason));
9090

9191
#line default
9292
#line hidden
@@ -250,7 +250,7 @@ public virtual string TransformText()
250250
this.Write(" [Obsolete(\"");
251251

252252
#line 50 "C:\Code\Github\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Class\ClassTemplate.tt"
253-
this.Write(this.ToStringHelper.ToStringWithCulture(field.DeprecationReason));
253+
this.Write(this.ToStringHelper.ToStringWithCulture(field.SafeDeprecationReason));
254254

255255
#line default
256256
#line hidden
@@ -332,7 +332,7 @@ public virtual string TransformText()
332332
this.Write(" [Obsolete(\"");
333333

334334
#line 61 "C:\Code\Github\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Class\ClassTemplate.tt"
335-
this.Write(this.ToStringHelper.ToStringWithCulture(field.DeprecationReason));
335+
this.Write(this.ToStringHelper.ToStringWithCulture(field.SafeDeprecationReason));
336336

337337
#line default
338338
#line hidden

0 commit comments

Comments
 (0)