Is There a Way to Add All .NET Object Names to My Dictionary

1

0

Is there a way to add all the .NET object names to my dictionary in MS-Word? I use them a lot when writing daily progress notes or documentation and it would be nice if auto-correct didn't chide me every time, but actually helped me identify the correct word I am looking for. I know how to add a single word manually, but that is not an option. Is there a quick/built-in way to add all these names, or do I need to edit a file programatically?

Joel B

Posted 2013-08-16T13:04:59.247

Reputation: 1 075

How are you manually doing this? – Austin T French – 2013-08-16T13:15:07.883

@AthomSfere - there's a couple of ways to "manually" add a single word such as typing it and right-click>add to dictionary or this answer

– Joel B – 2013-08-16T13:17:20.770

@JoelB: Rather than right-clicking them individually it is easier to press F7 to show the spelling dialog and then for each one click Add to Dictionary (Alt + A). – James P – 2013-08-16T13:41:57.663

There are thousands of classes in the base system assemblies (system, mscorlib) but if you take into account other assemblies like system.web you get a huge number. Also don't forget that many method names will also cause the spell checker to complain. That is why I think it is easier to add the names manually using the method above. – James P – 2013-08-16T14:02:12.210

Another option: If you use a specific style(s) in your documents for .NET code you can disable spelling checking for it. (Google disable spell checking for code in Microsoft Word). – Brian – 2013-08-18T05:23:08.663

Answers

1

This should work from PowerShell:

$net4 = gci "C:\Windows\Microsoft.NET\Framework\v4.0.30319" | Where-Object {$_.Extension -eq ".dll"}

$net4 | ForEach-Object {
$_.name | Out-File "C:\Users\YourUser\AppData\Roaming\Microsoft\UProof\CUSTOM.DIC" -Append
}

You could either have it loop through all frameworks to be safe, or do it once for each .NET directory.

Also, if you want the filename without the extension (.dll) use $_.Basename


Update: Ran the script and it did work for me. I added the libraries this way, mscorlib for example.


I am also able to get methods:

$net4 = gci "C:\Windows\Microsoft.NET\assembly\GAC_MSIL\" -Recurse -Force | Where-Object {$_.Extension -eq ".dll"}

$Methods

$net4 | ForEach-Object {

$Methods += $_ | Get-Member -Force -View All | Select -ExpandProperty Name

}

$Methods | Out-File "C:\Users\UserName\AppData\Roaming\Microsoft\UProof\CUSTOM.DIC" -Append

And it gets me (among lots, lots more):

OpenWrite
Refresh
Replace
SetAccessControl
set_Attributes
set_CreationTime
set_CreationTimeUtc
set_IsReadOnly
set_LastAccessTime
set_LastAccessTimeUtc
set_LastWriteTime
set_LastWriteTimeUtc
ToString
PSChildName
PSDrive
PSIsContainer
PSParentPath
PSPath
PSProvider
Attributes

Now the problem is there are many duplicates, but from here it should be simpler.

You could also use the C:\Windows\Microsoft.NET\Framework directories instead of the GAC if you wish.

Austin T French

Posted 2013-08-16T13:04:59.247

Reputation: 9 766

This is close. This, at best, only adds the DLL name which is not the object name. Objects are contained within the DLL and I'm looking for those names (things like ISerializeable or DivideByZeroException) to be added to my dictionary. – Joel B – 2013-08-16T13:50:27.777

Ah, that crossed my mind later. I will have to think about if I can expand with that in mind. – Austin T French – 2013-08-16T14:08:36.387

I asked here because I was hoping a PowerShell script could do it, but I think this is going to be a .NET only game using Reflection. – Joel B – 2013-08-16T14:11:45.233

1PowerShell can use reflection... And that's precisely what I am looking for. – Austin T French – 2013-08-16T15:04:58.033