You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "laimis (via GitHub)" <gi...@apache.org> on 2023/04/13 17:24:22 UTC
[GitHub] [lucenenet] laimis opened a new pull request, #829: Adjust QueryTemplateManager to allow subclasses avoid calling virtual methods from the constructors
laimis opened a new pull request, #829:
URL: https://github.com/apache/lucenenet/pull/829
Continuation of fixes with virtual calls being made from constructors. The issue originally reported by SonarCloud scans: https://sonarcloud.io/project/issues?resolved=false&rules=csharpsquid%3AS1699&id=apache_lucenenet and referenced in this issue: https://github.com/apache/lucenenet/issues/670
This one focuses on queryTemplateManager where we allow subclasses to use default constructor and expose m_defaultCompiledTemplates as protected for them to initialize it when needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [lucenenet] laimis commented on a diff in pull request #829: Adjust QueryTemplateManager to allow subclasses avoid calling virtual methods from the constructors
Posted by "laimis (via GitHub)" <gi...@apache.org>.
laimis commented on code in PR #829:
URL: https://github.com/apache/lucenenet/pull/829#discussion_r1165921148
##########
src/Lucene.Net.QueryParser/Xml/QueryTemplateManager.cs:
##########
@@ -34,20 +35,28 @@ namespace Lucene.Net.QueryParsers.Xml
public class QueryTemplateManager
{
private readonly IDictionary<string, XslCompiledTransform> compiledTemplatesCache = new Dictionary<string, XslCompiledTransform>(); // LUCENENET: marked readonly
- private XslCompiledTransform defaultCompiledTemplates;
+ // LUCENENET specific - made protected to allow subclasses to access and initialize
+ protected XslCompiledTransform m_defaultCompiledTemplates;
Review Comment:
oh ok, so basically no need to make this variable protected. Adjusting now...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [lucenenet] NightOwl888 commented on a diff in pull request #829: Adjust QueryTemplateManager to allow subclasses avoid calling virtual methods from the constructors
Posted by "NightOwl888 (via GitHub)" <gi...@apache.org>.
NightOwl888 commented on code in PR #829:
URL: https://github.com/apache/lucenenet/pull/829#discussion_r1165918115
##########
src/Lucene.Net.QueryParser/Xml/QueryTemplateManager.cs:
##########
@@ -34,20 +35,28 @@ namespace Lucene.Net.QueryParsers.Xml
public class QueryTemplateManager
{
private readonly IDictionary<string, XslCompiledTransform> compiledTemplatesCache = new Dictionary<string, XslCompiledTransform>(); // LUCENENET: marked readonly
- private XslCompiledTransform defaultCompiledTemplates;
+ // LUCENENET specific - made protected to allow subclasses to access and initialize
+ protected XslCompiledTransform m_defaultCompiledTemplates;
Review Comment:
It looks like this was meant to be a "default template" and the user could subclass to add their own template. To do this they would need to:
1. Override the `public QueryTemplateManager()` constructor.
2. Load their own template. However they want to.
3. Set their own private `XslCompiledTransform` to a private variable.
4. Override `GetQueryAsXmlString` and `GetQueryAsDOM` to supply their private variable.
Maybe I have missed something, but I don't think there is any advantage to making this variable protected as it is supposed to represent the "default" template, not the user specified one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [lucenenet] laimis merged pull request #829: Adjust QueryTemplateManager to allow subclasses avoid calling virtual methods from the constructors
Posted by "laimis (via GitHub)" <gi...@apache.org>.
laimis merged PR #829:
URL: https://github.com/apache/lucenenet/pull/829
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org