Skip to content

Commit

Permalink
fix: add C# options descriptions in the playground
Browse files Browse the repository at this point in the history
Part of Add descriptions for options in playground continued.. #1392

Signed-off-by: Kartik Jolapara <[email protected]>
  • Loading branch information
codingmickey committed Jun 18, 2023
1 parent a58108f commit eba3712
Showing 1 changed file with 121 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { PlaygroundCSharpConfigContext } from '@/components/contexts/PlaygroundConfigContext';
import Select from '@/components/Select';
import { debounce } from 'lodash';
import InfoModal from '@/components/InfoModal';

interface CSharpGeneratorOptionsProps {
setNewConfig?: (queryKey: string, queryValue: string) => void;
Expand All @@ -23,10 +24,13 @@ class CSharpGeneratorOptions extends React.Component<
super(props);
this.state = defaultState;
this.onChangeArrayType = this.onChangeArrayType.bind(this);
this.onChangeAutoImplementProperties = this.onChangeAutoImplementProperties.bind(this);
this.onChangeOverwriteHashCodeSupport = this.onChangeOverwriteHashCodeSupport.bind(this);
this.onChangeAutoImplementProperties =
this.onChangeAutoImplementProperties.bind(this);
this.onChangeOverwriteHashCodeSupport =
this.onChangeOverwriteHashCodeSupport.bind(this);
this.onChangeIncludeJson = this.onChangeIncludeJson.bind(this);
this.onChangeOverwriteEqualSupport = this.onChangeOverwriteEqualSupport.bind(this);
this.onChangeOverwriteEqualSupport =
this.onChangeOverwriteEqualSupport.bind(this);
this.onChangeIncludeNewtonsoft = this.onChangeIncludeNewtonsoft.bind(this);
this.onChangeNullable = this.onChangeNullable.bind(this);
this.onChangeNamespace = this.onChangeNamespace.bind(this);
Expand Down Expand Up @@ -62,7 +66,7 @@ class CSharpGeneratorOptions extends React.Component<
this.props.setNewConfig('csharpOverwriteEqual', event.target.checked);
}
}

onChangeIncludeNewtonsoft(event: any) {
if (this.props.setNewConfig) {
this.props.setNewConfig('csharpIncludeNewtonsoft', event.target.checked);
Expand All @@ -80,7 +84,7 @@ class CSharpGeneratorOptions extends React.Component<
}

onChangeNamespace(event: any) {
this.setState({ ...this.state, namespace: event.target.value })
this.setState({ ...this.state, namespace: event.target.value });
if (this.props.setNewConfig) {
this.debouncedSetNewConfig('csharpNamespace', event.target.value);
}
Expand All @@ -94,8 +98,18 @@ class CSharpGeneratorOptions extends React.Component<
<h3 className="text-lg font-medium leading-6 text-gray-900">
CSharp Specific options
</h3>
<li>
<label className="flex items-center py-2 justify-between cursor-pointer">
<li className="flex items-center">
<InfoModal text="Package Name :">
<p>
In C#, a namespace is used to organize code into logical groups
and avoid naming conflicts. It provides a way to uniquely identify
classes, structs, interfaces, and other types within a project. By
specifying a namespace for the generated C# data models, you can
control their visibility and easily reference them in other parts
of your code.
</p>
</InfoModal>
<label className="flex flex-grow items-center py-2 justify-between cursor-pointer">
<span className="mt-1 max-w-2xl text-sm text-gray-500">
Namespace
</span>
Expand All @@ -108,8 +122,24 @@ class CSharpGeneratorOptions extends React.Component<
/>
</label>
</li>
<li>
<label className="flex items-center py-2 justify-between cursor-pointer">
<li className="flex items-center">
<InfoModal text="Package Name :">
<p>
In C#, arrays are used to store collections of elements of the
same type. The <strong>C# array type</strong> option determines
how arrays are represented in the generated C# data models. If you
choose the
<strong>array</strong> type, the models will use the C# array
syntax, such as int[] or string[].
<br />
<br />
Alternatively, if you choose the <strong>List</strong> type, the
models will use the List&lt;T&gt; class from the
System.Collections.Generic namespace, providing additional
functionality and flexibility for working with collections.
</p>
</InfoModal>
<label className="flex flex-grow items-center py-2 justify-between cursor-pointer">
<span className="mt-1 max-w-2xl text-sm text-gray-500">
C# array type
</span>
Expand All @@ -124,8 +154,20 @@ class CSharpGeneratorOptions extends React.Component<
/>
</label>
</li>
<li>
<label className="flex items-center py-2 justify-between cursor-pointer">
<li className="flex items-center">
<InfoModal text="Package Name :">
<p>
Auto-implemented properties in C# allow you to define properties
without explicitly writing the backing field. The compiler
automatically generates the backing field and the get/set methods
for you. When the{' '}
<strong>Include auto-implemented properties</strong> option is
enabled, the generated C# data models will use this simplified
syntax for property declarations, reducing the amount of
boilerplate code you need to write.
</p>
</InfoModal>
<label className="flex flex-grow items-center py-2 justify-between cursor-pointer">
<span className="mt-1 max-w-2xl text-sm text-gray-500">
Include auto-implemented properties
</span>
Expand All @@ -138,8 +180,20 @@ class CSharpGeneratorOptions extends React.Component<
/>
</label>
</li>
<li>
<label className="flex items-center py-2 justify-between cursor-pointer">
<li className="flex items-center">
<InfoModal text="Package Name :">
<p>
In C#, the GetHashCode() method is used to generate a hash code
for an object. This method is often overridden when you need to
define custom equality comparisons or store objects in hash-based
data structures. By enabling the{' '}
<strong>Include Overwrite HashCode Support</strong> option, the
generated C# data models will include support for overwriting the
GetHashCode() method, allowing you to customize the hash code
calculation based on the model&apos;s properties.
</p>
</InfoModal>
<label className="flex flex-grow items-center py-2 justify-between cursor-pointer">
<span className="mt-1 max-w-2xl text-sm text-gray-500">
Include Overwrite HashCode Support
</span>
Expand All @@ -152,8 +206,21 @@ class CSharpGeneratorOptions extends React.Component<
/>
</label>
</li>
<li>
<label className="flex items-center py-2 justify-between cursor-pointer">
<li className="flex items-center">
<InfoModal text="Package Name :">
<p>
The Equals() method in C# is used to compare two objects for
equality. By default, it performs reference equality comparison.
However, in certain cases, you may want to override this method to
provide custom equality logic based on specific properties or
criteria. Enabling the{' '}
<strong>Include Overwrite Equal Support</strong> option in the
generated C# data models includes support for overwriting the
Equals() method, allowing you to define your own equality
comparisons.
</p>
</InfoModal>
<label className="flex flex-grow items-center py-2 justify-between cursor-pointer">
<span className="mt-1 max-w-2xl text-sm text-gray-500">
Include Overwrite Equal Support
</span>
Expand All @@ -166,8 +233,19 @@ class CSharpGeneratorOptions extends React.Component<
/>
</label>
</li>
<li>
<label className="flex items-center py-2 justify-between cursor-pointer">
<li className="flex items-center">
<InfoModal text="Package Name :">
<p>
In C#, JSON serialization is the process of converting an object
to its JSON representation and vice versa. Enabling the{' '}
<strong>Include JSON serialization</strong> option in the
generated C# data models includes the necessary attributes and
code to facilitate JSON serialization, making it easy to serialize
the models to JSON format or deserialize JSON data into instances
of the models.
</p>
</InfoModal>
<label className="flex flex-grow items-center py-2 justify-between cursor-pointer">
<span className="mt-1 max-w-2xl text-sm text-gray-500">
Include JSON serialization
</span>
Expand All @@ -180,8 +258,19 @@ class CSharpGeneratorOptions extends React.Component<
/>
</label>
</li>
<li>
<label className="flex items-center py-2 justify-between cursor-pointer">
<li className="flex items-center">
<InfoModal text="Package Name :">
<p>
Newtonsoft.Json (Json.NET) is a popular third-party JSON
serialization library for C#. It provides advanced features and
customization options for working with JSON data. When the
<strong>Include Newtonsoft serialization</strong> option is
enabled in the generated C# data models, the necessary attributes
and code are included to support serialization and deserialization
using the Json.NET library.
</p>
</InfoModal>
<label className="flex flex-grow items-center py-2 justify-between cursor-pointer">
<span className="mt-1 max-w-2xl text-sm text-gray-500">
Include Newtonsoft serialization
</span>
Expand All @@ -194,8 +283,19 @@ class CSharpGeneratorOptions extends React.Component<
/>
</label>
</li>
<li>
<label className="flex items-center py-2 justify-between cursor-pointer">
<li className="flex items-center">
<InfoModal text="Package Name :">
<p>
In C#, the nullable feature allows you to explicitly indicate
whether a value type (such as int, bool, etc.) or a reference type
(such as a class) can accept null values. By enabling the
<strong>Nullable</strong> option in the generated C# data models,
you allow properties to be nullable, meaning they can have a null
value in addition to their normal value range. This provides
flexibility when dealing with optional or unknown data values.
</p>
</InfoModal>
<label className="flex flex-grow items-center py-2 justify-between cursor-pointer">
<span className="mt-1 max-w-2xl text-sm text-gray-500">
Nullable
</span>
Expand Down

0 comments on commit eba3712

Please sign in to comment.