From eba3712f32939e9e3fb12b72be856cb44a364bee Mon Sep 17 00:00:00 2001 From: Kartik Jolapara Date: Mon, 19 Jun 2023 01:20:33 +0530 Subject: [PATCH 1/3] fix: add C# options descriptions in the playground Part of Add descriptions for options in playground continued.. #1392 Signed-off-by: Kartik Jolapara --- .../options/CSharpGeneratorOptions.tsx | 142 +++++++++++++++--- 1 file changed, 121 insertions(+), 21 deletions(-) diff --git a/modelina-website/src/components/playground/options/CSharpGeneratorOptions.tsx b/modelina-website/src/components/playground/options/CSharpGeneratorOptions.tsx index 0619151b2a..de58096e89 100644 --- a/modelina-website/src/components/playground/options/CSharpGeneratorOptions.tsx +++ b/modelina-website/src/components/playground/options/CSharpGeneratorOptions.tsx @@ -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; @@ -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); @@ -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); @@ -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); } @@ -94,8 +98,18 @@ class CSharpGeneratorOptions extends React.Component<

CSharp Specific options

-
  • -
  • + +

    + 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. +

    +
    +
  • -
  • -
  • + +

    + In C#, arrays are used to store collections of elements of the + same type. The C# array type option determines + how arrays are represented in the generated C# data models. If you + choose the + array type, the models will use the C# array + syntax, such as int[] or string[]. +
    +
    + Alternatively, if you choose the List type, the + models will use the List<T> class from the + System.Collections.Generic namespace, providing additional + functionality and flexibility for working with collections. +

    +
    +
  • -
  • -
  • + +

    + 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{' '} + Include auto-implemented properties 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. +

    +
    +
  • -
  • -
  • + +

    + 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{' '} + Include Overwrite HashCode Support 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's properties. +

    +
    +
  • -
  • -
  • + +

    + 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{' '} + Include Overwrite Equal Support option in the + generated C# data models includes support for overwriting the + Equals() method, allowing you to define your own equality + comparisons. +

    +
    +
  • -
  • -
  • + +

    + In C#, JSON serialization is the process of converting an object + to its JSON representation and vice versa. Enabling the{' '} + Include JSON serialization 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. +

    +
    +
  • -
  • -
  • + +

    + 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 + Include Newtonsoft serialization 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. +

    +
    +
  • -
  • -
  • + +

    + 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 + Nullable 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. +

    +
    +
  • - -

    +

  • + +

    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 @@ -123,14 +123,13 @@ class CSharpGeneratorOptions extends React.Component<

  • - -

    + +

    In C#, arrays are used to store collections of elements of the - same type. The C# array type option determines - how arrays are represented in the generated C# data models. If you - choose the - array type, the models will use the C# array - syntax, such as int[] or string[]. + same type. The C# array type option + determines how arrays are represented in the generated C# data + models. If you choose the array type, the models will use the C# array syntax, + such as int[] or string[].

    Alternatively, if you choose the List type, the @@ -154,9 +153,9 @@ class CSharpGeneratorOptions extends React.Component< />

  • -
  • - -

    +

  • + +

    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 @@ -180,9 +179,9 @@ class CSharpGeneratorOptions extends React.Component< />

  • -
  • - -

    +

  • + +

    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 @@ -190,7 +189,7 @@ class CSharpGeneratorOptions extends React.Component< Include Overwrite HashCode Support 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's properties. + calculation based on the model's properties.

  • -
  • - -

    +

  • + +

    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 @@ -233,9 +232,9 @@ class CSharpGeneratorOptions extends React.Component< />

  • -
  • - -

    +

  • + +

    In C#, JSON serialization is the process of converting an object to its JSON representation and vice versa. Enabling the{' '} Include JSON serialization option in the @@ -258,9 +257,9 @@ class CSharpGeneratorOptions extends React.Component< />

  • -
  • - -

    +

  • + +

    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 @@ -283,9 +282,9 @@ class CSharpGeneratorOptions extends React.Component< />

  • -
  • - -

    +

  • + +

    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 From b9452354dd8314a95b9843225e56d1f8632f9b36 Mon Sep 17 00:00:00 2001 From: Kartik Jolapara Date: Tue, 20 Jun 2023 00:01:10 +0530 Subject: [PATCH 3/3] fix(website): spacing between the text and the strong tag in option description Signed-off-by: Kartik Jolapara --- .../options/CSharpGeneratorOptions.tsx | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/modelina-website/src/components/playground/options/CSharpGeneratorOptions.tsx b/modelina-website/src/components/playground/options/CSharpGeneratorOptions.tsx index ca0fff86ee..eec5f32676 100644 --- a/modelina-website/src/components/playground/options/CSharpGeneratorOptions.tsx +++ b/modelina-website/src/components/playground/options/CSharpGeneratorOptions.tsx @@ -159,8 +159,7 @@ class CSharpGeneratorOptions extends React.Component< 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{' '} - Include auto-implemented properties option is + for you. When the Include auto-implemented properties 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. @@ -185,8 +184,7 @@ class CSharpGeneratorOptions extends React.Component< 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{' '} - Include Overwrite HashCode Support option, the + data structures. By enabling the Include Overwrite HashCode Support 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's properties. @@ -212,8 +210,7 @@ class CSharpGeneratorOptions extends React.Component< 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{' '} - Include Overwrite Equal Support option in the + criteria. Enabling the Include Overwrite Equal Support option in the generated C# data models includes support for overwriting the Equals() method, allowing you to define your own equality comparisons. @@ -236,8 +233,7 @@ class CSharpGeneratorOptions extends React.Component<

    In C#, JSON serialization is the process of converting an object - to its JSON representation and vice versa. Enabling the{' '} - Include JSON serialization option in the + to its JSON representation and vice versa. Enabling the Include JSON serialization 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 @@ -262,8 +258,7 @@ class CSharpGeneratorOptions extends React.Component<

    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 - Include Newtonsoft serialization option is + customization options for working with JSON data. When the Include Newtonsoft serialization 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. @@ -287,8 +282,7 @@ class CSharpGeneratorOptions extends React.Component<

    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 - Nullable option in the generated C# data models, + (such as a class) can accept null values. By enabling the Nullable 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.