Unable to inherit 'SqlScriptGenerator' class
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with the SqlScriptGenerator, SqlScriptGeneratorVisitor, ScriptWriter, and Sql100ScriptGenerator signatures shown in the issue. Review how the visitor and writer are currently constructed, then determine the public/protected API changes needed for an external subclass to compile. Done means a custom SqlScriptGenerator can inherit and override the visitor factory without relying on internal types.
Written by the indexing model from the issue text.
Description
Is your feature request related to a problem? Please describe.
Consider the following code to inherit SqlScriptGenerator
internal class CustomSqlScriptGenerator : SqlScriptGenerator
{
public CustomSqlScriptGenerator(SqlScriptGeneratorOptions options) : base(options)
{
}
internal override SqlScriptGeneratorVisitor CreateSqlScriptGeneratorVisitor(SqlScriptGeneratorOptions options, ScriptWriter scriptWriter)
{
throw new NotImplementedException();
}
}
However, this will get compilation error because SqlScriptGeneratorVisitor and ScriptWriter are marked as internal, which is impossible to inherit this class.
Describe the solution you'd like
- Change
CreateSqlScriptGeneratorVisitor(...)becomeprotectedinstead ofinternal - Remove
ScriptWriterparameter inCreateSqlScriptGeneratorVisitor(...). This can avoid to markScriptWriteraspublic. Instantiation ofScriptWriterwill be handled by child class ofSqlScriptGenerator. See example below. - Mark
SqlScriptGeneratorVisitoras public accessible.SqlScriptGeneratorVisitorwill be used to visit the expression tree when generating TSQL script.
Here is the suggested changes:
protected abstract SqlScriptGeneratorVisitor CreateSqlScriptGeneratorVisitor(SqlScriptGeneratorOptions options);
And update Sql###ScriptGenerator become
Example:
public sealed class Sql100ScriptGenerator : SqlScriptGenerator
{
public Sql100ScriptGenerator()
: this(new SqlScriptGeneratorOptions())
{
}
public Sql100ScriptGenerator(SqlScriptGeneratorOptions options)
: base(options)
{
}
protected override SqlScriptGeneratorVisitor CreateSqlScriptGeneratorVisitor(SqlScriptGeneratorOptions options)
{
// Create instance of ScriptWriter.
//Currently this is created by private function in SqlScriptGenerator
ScriptWriter scriptWriter = new ScriptWriter(options);
ScriptGeneratorSupporter.CheckForNullReference((object) options, nameof (options));
ScriptGeneratorSupporter.CheckForNullReference((object) scriptWriter, nameof (scriptWriter));
return (SqlScriptGeneratorVisitor) new Sql100ScriptGeneratorVisitor(options, scriptWriter);
}
}
- Dominant language
- GAP
- Stars
- 277
- Forks
- 43
- Avg merge
- 6d 17h
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/SqlScriptDOM
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
microsoft/SqlScriptDOM#228 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
microsoft/SqlScriptDOM#183 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 56/100
microsoft/SqlScriptDOM#226 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
microsoft/SqlScriptDOM#225 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
microsoft/SqlScriptDOM#224 ·
All issues in microsoft/SqlScriptDOM
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
AstrBotDevs/AstrBot#10205 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
OHDSI/Data2Evidence#3394 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100