Explain System.Diagnostics.CodeAnalysis.SuppressMessage - wpf

I have this kind of code in some applications (from microsoft)
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Naming",
"CA1702:CompoundWordsShouldBeCasedCorrectly",
MessageId = "CounterClockwise",
Scope = "member",
Target = "ScePhotoViewer.PhotoDisplayControl.#RotatePhotoCounterClockwiseCommand"
)]
Can anyone explain me this ?
Is there any blog explaining how to use it, the real benefits...
Thanks
Jonathan

This attribute is used by Team Foundation Server's (TFS) code analysis functionality to exclude code fragments that would otherwise trigger warnings. You can safely remove them if you're not using TFS code analysis.
The attributes can be added by hand or, more usually, are added automatically via the Visual Studio GUI when the "Suppress Message" option is selected in the error list.

This attribute simply suppresses the generation of the specified warning messages during code analysis by TFS. No code is is excluded.

Related

Read data for Inteliprompts in RadSyntaxEditor from dll or xml

RadSyntaxControl is newly created control from Telerik and has a feature for InteliPrompts but in every sample, I found out the user must manually populate CompletionInfoCollection, as you can see in this example.
CompletionInfoCollection completionList = new CompletionInfoCollection()
{
new CompletionInfo("Achitect", "A software developer expert.", Image.FromFile(#"../../SyntaxEditor/ Achitect.png")),
};
this.radSyntaxEditor1.SyntaxEditorElement.IntelliPrompts.CompletionListWindow.Presenter.CompletionListItems = completionList;
It is ok if there are just a few items for autocomplete but what in a case if I want to autocomplete for language like C#. Telerik has a syntax highlight for C#, but I cannot find a way to populate IntelliPromts with data in that manner.
The sample code is from Telerik Blogs
Thank you :)
Nenad,
As you have already found out, RadSyntaxEditor uses a CompletionInfoCollection to define intelliprompts which aim to speed up coding by reducing typos and other common mistakes. It is just necessary to define a separate CompletionInfo for each item that you want in the completion list window. It is up to you what list to be displayed and how you will get this information. This job is not intended to be done by the RadSyntaxEditor control. Additional information is available in the following help article: https://docs.telerik.com/devtools/winforms/controls/syntax-editor/features/intelliprompts
I have researched in the forums and since the English version of IntelliSense files are embedded in Visual Studio, I have found the following MSDN article which offers different language packs for the IntelliSense. Hence, you can at least use it to investigate what are the keywords and replace the translation according to your needs: https://learn.microsoft.com/en-us/dotnet/core/install/localized-intellisense
I hope this information helps.

Loading GLUquadric objects as a text file into opengl windows form

I have Created an OpenGL view on a Windows Form as on this and successfully embedded opengl into visual c++ windows form.Accordingly I have 2 files - rendering.h and opengl.h
Here's my original code....
Well then I extended my "OpenGL View on Windows Form" and combined it with NeHe's Tutorial "LESSON 27 - SHADOWS" and brought the code without errors. But still I have an obstacle!
Link error:
1> Generating Code...
1>PhotoRealisticRendering.obj : warning LNK4248: unresolved typeref token (0100002F) for 'GLUquadric'; image may not run
1>OpenGL.obj : warning LNK4248: unresolved typeref token (0100001B) for 'GLUquadric'; image may not run
Below are other 2 important files - shadow.h and 3Dobject.h
You're confusing GLUT with OpenGL. GLUT is a simplicistic application framework for creating a window and simple user interaction. You're not required to use GLUT at all.
You're using Windows Forms, which means, that is your framework. Using GLUT makes no sense then. You have to use the input event handling methods of Windows Forms. Here's an article on how to do it on MSDN: http://msdn.microsoft.com/en-us/library/ms171538(v=vs.110).aspx?cs-save-lang=1&cs-lang=cpp#code-snippet-1
EDIT: looking at the code you provided, it seems there's no relation between the keys array and your ProcessKeyboard callback. See for instance this answer.
(Original post snipped out, as not a good advice in this context, as stated by datenwolf)
-- Providing an excerpt of your source code always help to clarify/answer questions

The tag 'XXX' does not exist in XML namespace 'clr-namespace:YYY'

I have implemented a converter to convert Int32 to String to be able to binding a property to a textBox.
I implement this converter in the namespace MyApp.Converters and it is called Int32ToStringConverter.
Then, in my axml I add the reference to my converter as follow:
<Window x:Class="MusicaDB.Views.PrincipalView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
**xmlns:converter="clr-namesapce:MyApp.Converters, aseembly=MyApp**">
Later, in windows.Resources I have:
<Window.Resources>
<**converter:Int32ToStringConverter** x:Key="Int32ToStringConverter" />
</Window.Resources>
I get the error that the tag Int32ToString converter does not exist in the namespace MyApp.Converters,assembly=MyApp.
I have the project in the local hard drive, in the project properties, the destination .NET is framework 4.0, not framework 4.0 client profile and I try to clear the solution and recompile but the problem persists.
Mainly, this is the two solutions that I always find, but don't resolve my problem.
Three fixes to make here:
No spaces -> xmlns:converter="clr-namesapce:MyApp.Converters,aseembly=MyApp"
No misspellings -> xmlns:converter="clr-namespace:MyApp.Converters,assembly=MyApp"
Right delimiters -> xmlns:converter="clr-namespace:MyApp.Converters;assembly=MyApp"
From the the documentation:
Note that the character separating the clr-namespace token from its value is a colon (:) whereas the character separating the assembly token from its value is an equals sign (=). The character to use between these two tokens is a semicolon. Also, do not include any whitespace anywhere in the declaration.
Another possible solution to this problem is that you're not using the same version of .Net in your project and your library.
I am exploring as to why this is happening, but if your converter is in the main assembly, removing the assembly= from your xmlns:converters tag should remove that build error.
For the record ...
I've face a similar problem and if I removed the ";assembly=X" part from the XAML it worked fine
But don't really understand the reason.
As suggested in this blog:
http://zoomicon.wordpress.com/2012/07/02/fix-the-tag-xxx-does-not-exist-in-xml-namespace-clr-namespaceyyy/#comment-7761
I see two possible causes. The first is that you misspelled "assembly" as "aseembly" in the first starred line. Changing the spelling might be enough. The second possibility is that you haven't added MyApp.dll to your project references, which appear like this
in Visual Studio.
All answers are right. And after trying all of them and you cannot configure why its happening, everything seems alright, Please restart the Visual studio.
That worked for me after wasting almost 1 hour. I found everything ok, but restarted the VS with administration.
use the assemble tag only if it is in another project.
other wise use just namespace tag alone.
For me this fixed the issue
In my situation, I had the same problem with xmlns:local="clr-namespace:<mydefaultnamespace>".
I solved this changing the order of the includes. I put it first and all was solved.
A strange behaviour, but this was my workaround that I found in my situation.
In my case, the assembly which contained the namespace was not physically there.
I checked the references of the assembly that had the build error and looked at the properties of the referenced assembly in question.
I navigated to the path and discovered the assembly was indeed missing (which I realised was my own doing), giving rise to the misleading error.
There is one very obscure case when you get this error - if you're using Microsoft.mshtml.dll and you upgrade to Windows 10 anniversary edition, or as it turns out the Creator edition too.
Even if this isn't what happens to you make sure the library containing the component that cannot be found can be fully compiled. Look in the error list (not the grid but the Output console) for any clues.
In my case I was using Microsoft.mshtml.dll as part of an HTML editor and it was unregistered somehow (in the GAC).
The following article explains with screenshots:
https://techninotes.blogspot.com/2016/08/fixing-cannot-find-wrapper-assembly-for.html#comment-form
In short I had to run a Visual Studio command prompt (as admin) run these commands:
cd C:\Windows\assembly\GAC\Microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a
regasm Microsoft.mshtml.dll
I did say obscure :-) The important point is to read the errors that may be buried amongst all your warnings because there might be an important clue.
This can be especially confusing if an Operating system update suddenly breaks your project.
I was temporarily replacing a NuGet dll with a local one when this happened. Turned out the assembly was not the same version as the one I was replacing. I built my assembly with the correct version and it worked.

WPF Application project with a WF Activity in it generates errors on Generics types

I have a WPF Application with a subfolder that contains a WF Activity and a CodeActivity.
At compile-time on the Workflow that uses the CodeActivity, I get this error:
The tag 'Dictionary' does not exist in XML namespace 'clr-namespace:System.Collections.Generic;assembly=mscorlib'. Line 4 Position 8.
The portion of code that reports the error is generated by the Visual studio built-in Activity designer. E.g. this:
<sap:WorkflowViewStateService.ViewState>
<scg3:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">False</x:Boolean>
<av:Point x:Key="ShapeLocation">270,2.5</av:Point>
<av:Size x:Key="ShapeSize">60,75</av:Size>
<av:PointCollection x:Key="ConnectorLocation">300,77.5 300,107.5 300,112.5</av:PointCollection>
</scg3:Dictionary>
I'd like to know if I am trying to something that is not allowed or if I am missing something.
Thanks in advance,
Gianluca
I had a similar problem today; at least the same error message. The problem for me was that the build action of the .xaml file was set to Page. It needs to be set to XamlAppDef. If you open a vanilla Workflow console application project, you'll see that. You can't change it in the drop down, you need to edit the .csproj file (again, compare to vanilla VS workflow console project).

Warnings and errors (CS0436, CS0234) when creating user controls composed of other user controls in the same project

I'm working on a Windows Forms solution with many winform ui projects.
There is a class library project that contains some custom shared controls, named MyControls.
Now, when I create a control in MyControls
that is composed of one or more controls in the same project, I run into problems.
I either get compilation warnings: warning CS0436: The type 'MyType' in 'path-to\MyType.cs' conflicts with the imported type 'MyType' in 'MyControls.dll'. Using the type defined in 'path-to\MyType.cs'. Or I get a bunch of different compilation errors, all pointing to "MyControls.dll" (error CS0234 - "are you missing an assembly reference?").
I get either the errors, or the warnings, never both.
How to solve this?
Note
I added visual-studio-2010 because that's the version I experienced the problems with. No idea if this relates to other versions too.
I found that Visual Studio adds a self-reference to MyControls when I drop a control from the MyControls project on another control in MyControls:
<Reference Include="MyControls, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" />
My current work-around is to manually delete this reference from the MyControls.csproj using a text editor.
When I've done this, everything works fine, until I drop another control that triggers a self reference.
Better solutions are appreciated!
you can make a small and "legal" change in your solution and get the "legal" solution... lets say your project name is: "project01"
go to references folder in your project - one of your references called "project01" - just remove it...
the the warning is very fair! you design a form and in the other hand import your project as a reference!
I know this thread is a bit old, but I just went looking for a solution to this issue, and it seems that MS doesn't have anything other than what Marijn suggested earlier:
https://connect.microsoft.com/VisualStudio/feedback/details/613502/automatically-add-self-reference
Hopefully it's fixed in VS 2012.

Resources