How to fix semicolon missing errors automatically c#. I have an old project in which semicolon missing in most of the lines. how to include the missing semicolons automatically using visual studio or any other extension
Asked
Active
Viewed 393 times
-11
-
Manual fix will be required – Amit Verma Aug 24 '22 at 04:07
-
Cannot fix automatically? nearly 1800 lines need to edit – Marimuthu Narayanan Aug 24 '22 at 04:12
-
Add the missing semicolon? Or just write your code correctly in the first place. – ProgrammingLlama Aug 24 '22 at 04:12
-
Why would there be an automatic fix for a typo? Think about it. – ProgrammingLlama Aug 24 '22 at 04:13
-
Not a typo. It was an old project in vb.net. it happened like this when we converted it to c# – Marimuthu Narayanan Aug 24 '22 at 04:16
-
6Use a better tool to convert it to C# then. Evidently the tool you used was utter trash if it didn't add semicolons. – ProgrammingLlama Aug 24 '22 at 04:16
-
You could parse all your .cs files and then for each line append a semicolon. It shouldn't show an error if you have a double semicolon on the end of some lines. – Ibrennan208 Aug 24 '22 at 04:17
-
you can read the source file as text and append `;` at the end of line if does not exist. reference code: https://stackoverflow.com/a/1971052/223752 – Nitin Sawant Aug 24 '22 at 04:17
-
[field: AccessedThroughProperty("LayoutControlGroup1")] internal virtual LayoutControlGroup LayoutControlGroup1 { get; [MethodImpl(MethodImplOptions.Synchronized)] set; } the project has code like this. all the controls wre like this so we cannot open the designer page. is there a way to replace all the above code like this. public LayoutControlGroup LayoutControlGroup1; – Marimuthu Narayanan Aug 24 '22 at 04:18
-
1@Ibrennan208 In my mind I just see that ending up like [this](https://i.stack.imgur.com/Y3lXa.png) :D – ProgrammingLlama Aug 24 '22 at 04:19
-
1@DiplomacyNotWar Definitely :D haha, it would probably result in a similar amount of errors, but still an entertaining idea. – Ibrennan208 Aug 24 '22 at 04:22
-
internal virtual LayoutControlGroup LayoutControlGroup1 { get; [MethodImpl(MethodImplOptions.Synchronized)] set; } internal virtual SimpleButton BOK { [CompilerGenerated] get { return _BOK; } [MethodImpl(MethodImplOptions.Synchronized)] [CompilerGenerated] set { EventHandler value2 = BOK_Click; SimpleButton bOK = _BOK; if (bOK != null) { bOK.Click -= value2; } _BOK = value; bOK = _BOK; if (bOK != null) { bOK.Click += value2; } } } the code like this. so i cannot view the designer – Marimuthu Narayanan Aug 24 '22 at 04:26
1 Answers
0
I would do this:
- Open up Replace in file.
- Select "Use Regular Expressions".
- Enter ".$" in Search term (no quotes).
- Enter ";" in Replace term (no quotes).
Now do replace single or replace all. Replace all will add too many semicolons (blank lines and comments and all other), but will probably give less than 1800 errors to fix.
Tested it in Visual Studio 17.3.1.

emilsteen
- 496
- 4
- 14