This question is locked. New answers and comments are not allowed.
Hi,
I just tried to use "Clean code" - I built a clone and all I marked was
"Remove unused usings"
"Order usings"
First thing - I expected this would handle my whole project :)
I found this works only for the current file.
Which means I could also use "Organize and Add missing usings".
And - see below - both "version" provide the same unwanted result.
First a question - is there a way to do this (remove / sort usings) for all files in a project?
Because else I could also use the "internal" version which works better (of course as long as I don't have to add missing ones).
Why it works better?
The simple reason - JC (no mater if I use "Clean code" ot "Organize....") has a problem when no using is needed in a file.
I breaks my code formatting!
This how the code looks when a using is left (and that's my formatting - choosen in VS):
Notice the braces.
And a last thing about code formatting.
I have the following (bad formatted) code section:
Navigating to the end of the file - remve the last brace and enter it again (forces VS to format the code) brings this:
In options I set every brace position to "Same line".
Two things are wrong here:
a.) Singele line setters / getters (event if empty) become multiline
b.) after the backing field I get a newline
Is there a way to set the JC options that it could "reproduce" what VS does?
Thank you
Manfred
I just tried to use "Clean code" - I built a clone and all I marked was
"Remove unused usings"
"Order usings"
First thing - I expected this would handle my whole project :)
I found this works only for the current file.
Which means I could also use "Organize and Add missing usings".
And - see below - both "version" provide the same unwanted result.
First a question - is there a way to do this (remove / sort usings) for all files in a project?
Because else I could also use the "internal" version which works better (of course as long as I don't have to add missing ones).
Why it works better?
The simple reason - JC (no mater if I use "Clean code" ot "Organize....") has a problem when no using is needed in a file.
I breaks my code formatting!
This how the code looks when a using is left (and that's my formatting - choosen in VS):
Snippet created with CBEnhancer
using KBSM.Classes;
namespace KBSM.DataThings {
public partial class OL4Lock {
private bool m_bIsByteAssigning;
CustomerFileHelper cfH;
partial void OnOL4BytesChanged() {
if(!m_bIsByteAssigning) {
OL4_B0 = (byte)(OL4Bytes & 0xFF);
OL4_B1 = (byte)((OL4Bytes >> 8) & 0xFF);
OL4_B2 = (byte)((OL4Bytes >> 16) & 0xFF);
OL4_B3 = (byte)((OL4Bytes >> 24) & 0xFF);
SendPropertyChanged("OL4_Str");
}
}
partial void OnLoaded() {
OnOL4BytesChanged();
}
}
}
And this is how it looks when no using is left:using KBSM.Classes;
namespace KBSM.DataThings {
public partial class OL4Lock {
private bool m_bIsByteAssigning;
CustomerFileHelper cfH;
partial void OnOL4BytesChanged() {
if(!m_bIsByteAssigning) {
OL4_B0 = (byte)(OL4Bytes & 0xFF);
OL4_B1 = (byte)((OL4Bytes >> 8) & 0xFF);
OL4_B2 = (byte)((OL4Bytes >> 16) & 0xFF);
OL4_B3 = (byte)((OL4Bytes >> 24) & 0xFF);
SendPropertyChanged("OL4_Str");
}
}
partial void OnLoaded() {
OnOL4BytesChanged();
}
}
}
Snippet created with CBEnhancer
namespace KBSM.DataThings
{
public partial class OL4Lock
{
private bool m_bIsByteAssigning;
partial void OnOL4BytesChanged() {
if(!m_bIsByteAssigning) {
OL4_B0 = (byte)(OL4Bytes & 0xFF);
OL4_B1 = (byte)((OL4Bytes >> 8) & 0xFF);
OL4_B2 = (byte)((OL4Bytes >> 16) & 0xFF);
OL4_B3 = (byte)((OL4Bytes >> 24) & 0xFF);
SendPropertyChanged("OL4_Str");
}
}
partial void OnLoaded() {
OnOL4BytesChanged();
}
}
}
namespace KBSM.DataThings
{
public partial class OL4Lock
{
private bool m_bIsByteAssigning;
partial void OnOL4BytesChanged() {
if(!m_bIsByteAssigning) {
OL4_B0 = (byte)(OL4Bytes & 0xFF);
OL4_B1 = (byte)((OL4Bytes >> 8) & 0xFF);
OL4_B2 = (byte)((OL4Bytes >> 16) & 0xFF);
OL4_B3 = (byte)((OL4Bytes >> 24) & 0xFF);
SendPropertyChanged("OL4_Str");
}
}
partial void OnLoaded() {
OnOL4BytesChanged();
}
}
}
Notice the braces.
And a last thing about code formatting.
I have the following (bad formatted) code section:
Snippet created with CBEnhancer
#region OL4_Str
public string OL4_Str {
get { return OL4Bytes.ToString("X8"); }
set { }
}
#endregion
#region OL4_B0
private byte m_byOL4_B0;
public byte OL4_B0 {
get { return m_byOL4_B0; } set {
if(m_byOL4_B0 != value) { m_byOL4_B0 = value;
uint nTmp = (uint)OL4Bytes;
nTmp &= 0xffffff00;
nTmp |= m_byOL4_B0;
m_bIsByteAssigning = true;
OL4Bytes = (int)nTmp;
m_bIsByteAssigning = false;
OL4_B0Str = m_byOL4_B0.ToString("X2");
SendPropertyChanged("OL4_B0"); }
}
}
#endregion
#region OL4_Str
public string OL4_Str {
get { return OL4Bytes.ToString("X8"); }
set { }
}
#endregion
#region OL4_B0
private byte m_byOL4_B0;
public byte OL4_B0 {
get { return m_byOL4_B0; } set {
if(m_byOL4_B0 != value) { m_byOL4_B0 = value;
uint nTmp = (uint)OL4Bytes;
nTmp &= 0xffffff00;
nTmp |= m_byOL4_B0;
m_bIsByteAssigning = true;
OL4Bytes = (int)nTmp;
m_bIsByteAssigning = false;
OL4_B0Str = m_byOL4_B0.ToString("X2");
SendPropertyChanged("OL4_B0"); }
}
}
#endregion
Navigating to the end of the file - remve the last brace and enter it again (forces VS to format the code) brings this:
Snippet created with CBEnhancer
#region OL4_Str
public string OL4_Str {
get { return OL4Bytes.ToString("X8"); }
set { }
}
#endregion
#region OL4_B0
private byte m_byOL4_B0;
public byte OL4_B0 {
get { return m_byOL4_B0; }
set {
if(m_byOL4_B0 != value) {
m_byOL4_B0 = value;
uint nTmp = (uint)OL4Bytes;
nTmp &= 0xffffff00;
nTmp |= m_byOL4_B0;
m_bIsByteAssigning = true;
OL4Bytes = (int)nTmp;
m_bIsByteAssigning = false;
OL4_B0Str = m_byOL4_B0.ToString("X2");
SendPropertyChanged("OL4_B0");
}
}
}
#endregion
Using just code - format code brings this:#region OL4_Str
public string OL4_Str {
get { return OL4Bytes.ToString("X8"); }
set { }
}
#endregion
#region OL4_B0
private byte m_byOL4_B0;
public byte OL4_B0 {
get { return m_byOL4_B0; }
set {
if(m_byOL4_B0 != value) {
m_byOL4_B0 = value;
uint nTmp = (uint)OL4Bytes;
nTmp &= 0xffffff00;
nTmp |= m_byOL4_B0;
m_bIsByteAssigning = true;
OL4Bytes = (int)nTmp;
m_bIsByteAssigning = false;
OL4_B0Str = m_byOL4_B0.ToString("X2");
SendPropertyChanged("OL4_B0");
}
}
}
#endregion
Snippet created with CBEnhancer
#region OL4_Str
public string OL4_Str {
get {
return OL4Bytes.ToString("X8");
}
set {
}
}
#endregion
#region OL4_B0
private byte m_byOL4_B0;
public byte OL4_B0 {
get {
return m_byOL4_B0;
}
set {
if(m_byOL4_B0 != value) {
m_byOL4_B0 = value;
uint nTmp = (uint)OL4Bytes;
nTmp &= 0xffffff00;
nTmp |= m_byOL4_B0;
m_bIsByteAssigning = true;
OL4Bytes = (int)nTmp;
m_bIsByteAssigning = false;
OL4_B0Str = m_byOL4_B0.ToString("X2");
SendPropertyChanged("OL4_B0");
}
}
}
#endregion
#region OL4_Str
public string OL4_Str {
get {
return OL4Bytes.ToString("X8");
}
set {
}
}
#endregion
#region OL4_B0
private byte m_byOL4_B0;
public byte OL4_B0 {
get {
return m_byOL4_B0;
}
set {
if(m_byOL4_B0 != value) {
m_byOL4_B0 = value;
uint nTmp = (uint)OL4Bytes;
nTmp &= 0xffffff00;
nTmp |= m_byOL4_B0;
m_bIsByteAssigning = true;
OL4Bytes = (int)nTmp;
m_bIsByteAssigning = false;
OL4_B0Str = m_byOL4_B0.ToString("X2");
SendPropertyChanged("OL4_B0");
}
}
}
#endregion
In options I set every brace position to "Same line".
Two things are wrong here:
a.) Singele line setters / getters (event if empty) become multiline
b.) after the backing field I get a newline
Is there a way to set the JC options that it could "reproduce" what VS does?
Thank you
Manfred