What Resharper setting controls alignment of named call arguments in C#? - resharper

I got careless and broke it while fiddling. I don't know what I did. Cannot get it back. So this call which used to line up so nicely...
new ExportCsvOptions
(
directory : new DirectoryInfo(dir!),
writer : new StreamWriter(dlg.FileName, false, encoding),
profileOutputs : allOutputs.Where(o => o.PropType == PropType.Profile).ToList()
);
... now shows up like this, even after manually formatting.
new ExportCsvOptions
(
directory : new DirectoryInfo(dir!),
writer : new StreamWriter(dlg.FileName, false, encoding),
profileOutputs : allOutputs.Where(o => o.PropType == PropType.Profile).ToList()
);
My efforts to fix it have been limited to just this section
Code Editing >> C# >> Formatting Style >> Tabs Indents and Alignment >> Align Multiline Constructs
I have individually toggled the following checkboxes with no effect
Method Parameters
Call Arguments by '('
Call Arguments
Also, on that same page I have every single checkbox checked in "Align Similar Code in Columns" I've tried unchecking a few of them there. No effect.
I should add that that initializer blocks do continue to line up perfectly. So if I create the same object but just initialize the properties after the default constructor, they look great.
new ExportCsvOptions
{
Directory = new DirectoryInfo(dir!),
Writer = new StreamWriter(dlg.FileName, false, encoding),
ProfileOutputs = allOutputs.Where(o => o.PropType == PropType.Profile).ToList()
};
Also I am using the latest 2022.3.2 version

Related

Settings on ContainerPart on new type

I'm trying to create a new content type in a migration that has a ContainerPart attached with some settings already applied.
ContentDefinitionManager.AlterTypeDefinition("NewType",
cfg => cfg
.DisplayedAs("New Type")
.WithPart(typeof(TitlePart).Name)
.WithPart(typeof(ContainerPart).Name)
.WithSetting("ContainerPartSettings.ItemsShownDefault", "False")
.WithPart(typeof(CommonPart).Name)
.WithPart(typeof(IdentityPart).Name)
.Creatable()
.Listable()
);
ItemsShownDefault, after the migration, stays at its default value of True.
I've tried a few different variations of this:
Renaming "ContainerPartSettings" to other versions like ContainerSettings, ContainerTypePartSettings
Not using the typeof() function and specifying the part with a direct string
From what I can tell, ContainerSettings uses a different method to store its values compared to others like AutorouteSettings.
Looking at your code, your are chaining the settings on your type instead of the part:
.WithPart(typeof(ContainerPart).Name) // close the WithPart function
// which means the following line is chained to the type
.WithSetting("ContainerPartSettings.ItemsShownDefault", "False")
To fix this, do it like this:
.WithPart(typeof(ContainerPart).Name, part => part
// inside the ContainerPart context
.WithSetting("ContainerPartSettings.ItemsShownDefault", "False")
) // Close ContainerPart context
.WithPart(..)
If you did mean to set the settings on the type instead of the part, use the ContainerTypePartSettings class that is defined here:
.WithPart(typeof(ContainerPart).Name)
// Set settings on the type instead of the part
.WithSetting("ContainerTypePartSettings.ItemsShownDefault", false)

Issues adding source code to a custom DSL file programatically

I currently have a xtext grammar that looks like the following :
Features:
'feature' name = ID
'{'(
('action' '{' action+=Actions (',' action+=Actions)* '}')? &
('dependencies' '{' dependencies = Dependencies '}')? &
('children' '{' children = Children '}')?
)'}'
;
What I want to do with this is add an action to an already existing source file programatically, for that I am using the IUnitOfWork.Void class that I subclass for easier implementation , it currently looks like this (the meaningful part of it) :
final XtextEditor editor = (XtextEditor)sourcepart;
final IXtextDocument document = editor.getDocument();
document.modify(new IUnitOfWork.Void<XtextResource>(){
public void process (XtextResource resource) throws Exception {
IParseResult parseResult = resource.getParseResult();
if(parseResult ==null)
return;
CompositeNode rootNode=(CompositeNode) parseResult.getRootNode();
LeafNode node = (LeafNode)NodeModelUtils.findLeafNodeAtOffset(rootNode, 0);
EObject object =NodeModelUtils.findActualSemanticObjectFor(node);
Through this I traverse the tree of the model and get to my Features object to which I want to add an action to (this is done through a pop up menu in a custom Tree View I'm implementing)
Here's my problem : whenever I want to add an action it screws up the way the tags are placed in the source file , and by that I mean that instead of :
action {
act1.set (foo),
act2.set (bar),
act3.set (baz),
act4.set (booze) //where this is the new action that I add
}
it will add it as
action {
act1.set (foo),
act2.set (bar),
act3.set (baz)
}
action {
act4.set(booze)
}
And this is illegal by the rules of my grammar, and I'm not allowed to change the way it should be written. (I am allowed to make small changes to the way the rules are implemented, but would really want to avoid it as it would mean a whole new amount of work to reimplement other things that depend on them)
I've tried :
adding it directly through Features.getAction().add(*the new action);
copying the items in the list into an array with the toArray() method so as to avoid referencing, adding my action to the array, clearing the list then adding all the elements again one by one
creating an entirely new Features object and setting everything in it to be the same as the currently edited one then replacing the feature with the new one
And I'm out of ideas after that. The frustrating part is that the 3rd method worked for a different kind of object in my grammar and had no errors there.
How could I make this work ?
this is a bug in xtext. (can you please file a ticket?)
as a workaround you may use the following
Features:
'feature' name = ID
'{'(
('action' '{' actionList=ActionList '}')? &
('dependencies' '{' dependencies = Dependencies '}')? &
('children' '{' children = Children '}')?
)'}';
ActionList:
(action+=Action (',' action+=Action)*)
;

Can't modify/remove a field from an ActivityNode using sbt

I created an ActivityNode (an Entry) and I can add custom fields with the
setFields(List<Field> newListField)
fonction.
BUT
I am unable to modify these fields. (In this case I try to modify the value of the field named LIBENTITE)
FieldList list = myEntry.getTextFields();
List<Field> updatedList = new ArrayList<Field>();
//I add each old field in the new list, but I modify the field LIBENTITE
for(Field myField : list){
if(myField.getName().equals("LIBENTITE")){
((TextField)myField).setTextSummary("New value");
}
updatedList.add(myField);
}
myEntry.setFields(updatedList);
activityService.updateActivityNode(myEntry);
This code should replace the old list of fields with the new one, but I can't see any change in the custom field LIBENTITE of myEntry in IBM connections.
So I tried to create a new list of fields, not modifying my field but adding a new one :
for(Field myField:list){
if(!myField.getName().equals("LIBENTITE")){
updatedList.add(myField);
}
}
Field newTextField = new TextField("New Value");
newTextField .setFieldName("LIBENTITE");
updatedList.add(newTextField );
And this code is just adding the new field in myEntry. What I see is that the other custom fields did not change and I have now two custom fields named LIBENTITE, one with the old value and the second with the new value, in myEntry.
So I though that maybe if I clear the old list of Fields, and then I add the new one, it would work.
I tried the two fonctions
myEntry.clearFieldsMap();
and
myEntry.remove("LIBENTITE");
but none of them seems to work, I still can't remove a custom field from myEntry using SBT.
Any suggestions ?
I have two suggestions, as I had (or have) similar problems:
If you want to update an existing text field in an activity node, you have to call node.setField(fld) to update the field in the node object.
Code snippet from my working application, where I'm updating a text field containing a (computed) start time:
ActivityNode node = activityService.getActivityNode(id);
node.setTitle(formatTitle()); // add/update start and end time in title
boolean startFound = false;
// ...
FieldList textfields =node.getTextFields();
Iterator<Field> iterFields = textfields.iterator();
while (iterFields.hasNext()) {
TextField fld = (TextField) iterFields.next();
if (fld.getName().equals(Constants.FIELDNAME_STARTTIME)) {
fld.setTextSummary(this.getStartTimeString()); // NOTE: .setFieldValue does *not* work
node.setField(fld); // write updated field back. This seems to be the only way updating fields works
startFound=true;
}
}
If there is no field with that name, I create a new one (that's the reason I'm using the startFound boolean variable).
I think that the node.setField(fld) should do the trick. If not, there might be a way to sidestep the problem:
You have access to the underlying DOM object which was parsed in. You can use this to tweak the DOM object, which finally will be written back to Connections.
I had to use this as there seems to be another nasty bug in the SBT SDK: If you read in a text field which has no value, and write it back, an error will be thrown. Looks like the DOM object misses some required nodes, so you have to create them yourself to avoid the error.
Some code to demonstrate this:
// ....
} else if (null == fld.getTextSummary()) { // a text field without any contents. Which is BAD!
// there is a bug in the SBT API: if we read a field which has no value
// and try to write the node back (even without touching the field) a NullPointerException
// will be thrown. It seems that there is no value node set for the field. We
// can't set a value with fld.setTextSummary(), the error will still be thrown.
// therefore we have to remove the field, and - optionally - we set a defined "empty" value
// to avoid the problem.
// node.remove(fld.getName()); // remove the field -- this does *not* work! At least not for empty fields
// so we have to do it the hard way: we delete the node of the field in the cached dom structure
String fieldName = fld.getName();
DeferredElementNSImpl fldData = (DeferredElementNSImpl) fld.getDataHandler().getData();
fldData.getParentNode().removeChild(fldData); // remove the field from the cached dom structure, therefore delete it
// and create it again, but with a substitute value
Field newEmptyField = new TextField (Constants.FIELD_TEXTFIELD_EMPTY_VALUE); // create a field with a placeholder value
newEmptyField.setFieldName(fieldName);
node.setField(newEmptyField);
}
Hope that helps.
Just so that post does not stay unanswered I write the answer that was in a comment of the initial question :
"currently, there is no solution to this issue, the TextFields are read-only map. we have the issue recorded on github.com/OpenNTF/SocialSDK/issues/1657"

text field attributes/methods dynamics crm 2011

I'm looking a method or way how to check that the text field in crm form is "null"
I've got a tab, there are section and text field inside of it;
furthermore, I'm using that function in order to hide/show tab.
function setVisibleTabSection(tabname, TextFieldName, show) {
var tab = Xrm.Page.ui.tabs.get(tabname);
if (tab != null) {
if (TextFieldName == null)
tab.setVisible(show);
else {
var section = Xrm.Page.data.entity.attributes.get(TextFieldName).getValue();
if (section != null) {
show == true;
tab.setVisible(show);
}
}
}
}
however, It doesn't work. There is nothing inside of the text box, and the tab expanded anyway.
by the way, parameters, which I give the function: "tab_8", "new_conf_report", false
where the secon one the name of the text field
Try
if (section != null && section !="")...
You may find that a field which is initially blank is null, whereas one from which you have deleted content but not yet saved the form is simply an empty string.
Certainly worth a shot.
show==true
is incorrect as others have pointed out (needs to be show=true) but is simply redundant as written inside the same IF statement, just replace next line as:
tab.setVisible(true);
It is possible you intended "show" to be the default tab state to use if text field is not empty, in which case just move this line outside the IF instead of changing it (as shown below)
It looks like the construction using the third "show" parameter is to allow you to use the function to set the tab state to a specific state of shown or not without looking for a text field value at all. You would need to pass parameters as eg tabname,,true - you might consider swapping the TextFieldName and Show parameters so it is easier to just drop the third rather than remember to double-comma.
While we're fixing stuff, lets replace that variable "section" with something with a more meaningful name:
function setVisibleTabSection(tabname, show, TextFieldName) //usage: show is state Tab will have if no TextFieldName is specified, or if text field is empty
{
var tab = Xrm.Page.ui.tabs.get(tabname);
if (tab != null)
{
if (show==null){show=true;}
if (TextFieldName == null)
{
tab.setVisible(show);
}
else
{
var strFieldValue = Xrm.Page.data.entity.attributes.get(TextFieldName).getValue();
if (strFieldValue != null && strFieldValue !="")
{show=true;}
tab.setVisible(show);
}
}
}
I don't see anything wrong with your Javascript (besides what Guido points out, which basically will only set the tab to visible if you pass in true for show). Use the debugging tool within IE by pushing F12, and set a break point at the top of your function to see where your logic is failing.
If you've never debugged javascript before, see http://social.technet.microsoft.com/wiki/contents/articles/3256.how-to-debug-jscript-in-microsoft-dynamics-crm-2011.aspx
or
How to debug jScript for Dynamics CRM?
I think there is a typo in the code:
show == true;
actually the code (assuming "=" instead of "==") will show always the tab if TextFieldName isn't empty, removing that line will show/hide the tab according to show parameter value
It seems to work when I run it but I'm not sure what you'd expect it to do so it might not be working the way you'd like it to. :)
function setVisibleTabSection(tabName, textFieldName, show) {
var tab = Xrm.Page.ui.tabs.get(tabName);
if(!tab) return;
if (!TextFieldName)
tab.setVisible(show);
else {
var section = Xrm.Page.data.entity.attributes.get(textFieldName).getValue();
if (section)
tab.setVisible(true);
}
}

Masking QLineEdit text

I am using PyQt4 QLineEdit widget to accept password. There is a setMasking property, but not following how to set the masking character.
editor = QLineEdit()
editor.setEchoMode(QLineEdit.Password)
There is no setMasking property for QLineEdit in either PyQt4 or Qt4. Are you talking about setInputMask()? If you are, this does not do what you seem to think it does. It sets the mask against which to validate the input.
To get the control to hide what is typed, use the setEchoMode() method, which will (should) display the standard password hiding character for the platform. From what I can see from the documentation, if you want a custom character to be displayed, you will need to derive a new class. In general however, this is a bad idea, since it goes against what users expect to see.
It's quite easy using Qt: you would need to define a new style and return new character from the styleHint method whenever QStyle::SH_LineEdit_PasswordCharacter constant is queried. Below is an example:
class LineEditStyle : public QProxyStyle
{
public:
LineEditStyle(QStyle *style = 0) : QProxyStyle(style) { }
int styleHint(StyleHint hint, const QStyleOption * option = 0,
const QWidget * widget = 0, QStyleHintReturn * returnData = 0 ) const
{
if (hint==QStyle::SH_LineEdit_PasswordCharacter)
return '%';
return QProxyStyle::styleHint(hint, option, widget, returnData);
}
};
lineEdit->setEchoMode(QLineEdit::Password);
lineEdit->setStyle(new LineEditStyle(ui->lineEdit->style()));
now the problem is that pyqt doesn't seem to know anything about QProxyStyle; it seem to be not wrapped there, so you're stuck, unless you would want to wrap it yourself.
regards
As docs say http://doc-snapshot.qt-project.org/4.8/stylesheet-examples.html#customizing-qlineedit:
The password character of line edits that have QLineEdit::Password echo mode can be set using:
QLineEdit[echoMode="2"] {
lineedit-password-character: 9679;
}
In Qt Designer
Select the line edit, and in the Property Editor window, there will be a property echoMode which you can set to Password.
Using python code
In this case, Anti Earth's answer will work which is:
myLineEdit.setEchoMode(QLineEdit.Password)

Resources