I am building projects using a build definition. When this executes, Code Analysis is also performed. Code Analysis outputs various files including:
ConsoleApplication2.exe.CodeAnalysisLog.xml
ConsoleApplication2.exe.lastcodeanalysissucceeded
Is there any way to disable this output from happing in my build definition, say through parameters or something similar?
Generation of the success marker file can be disabled using the CodeAnalysisGenerateSuccessFile option. e.g.:
<CodeAnalysisGenerateSuccessFile>false</CodeAnalysisGenerateSuccessFile>
There's no option for preventing generation of the log file, but you can move it to some other location via the CodeAnalysisLogFile option. For example, to place it in your project root folder, you could use the following:
<CodeAnalysisLogFile>CodeAnalysisLog.xml</CodeAnalysisLogFile>
I have found an option for the lastcodeanalysissucceededfile.
By providing an input parameter: /p:CodeAnalysisGenerateSuccessFile=false, the file does not get generated.
I have yet to find an input parameter that disables the output of the logfile. The schemasettings as stated below did not cover it.
<xs:element name="CodeAnalysisInputAssembly" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisInputAssembly" _locComment="" -->Path to the assembly to be analyzed by Code Analysis. The default is '$(OutDir)$(TargetName)$(TargetExt)'.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisLogFile" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisLogFile" _locComment="" -->Path to the output file for the Code Analysis report. The default is '$(CodeAnalysisInputAssembly).CodeAnalysisLog.xml'.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisLogFileXsl" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisLogFileXsl" _locComment="" -->Path to the XSL style sheet to reference in the Code Analysis output report. This report is specified in $(CodeAnalysisLogFile). The default is an empty string ('').</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisModuleSuppressionsFile" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisModuleSuppressionsFile" _locComment="" -->Name of the file, without the path, where Code Analysis project-level suppressions are stored. The default is 'GlobalSuppressions$(DefaultLanguageSourceExtension)'.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisOverrideRuleVisibilities" type="msb:boolean" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisOverrideRuleVisibilities" _locComment="" -->Indicates whether to run all overridable Code Analysis rules against all targets. This will cause specific rules, such as those within the Design and Naming categories, to run against both public and internal APIs, instead of only public APIs. The default is false.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisOutputToConsole" type="msb:boolean" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisOutputToConsole" _locComment="" -->Indicates whether to output Code Analysis warnings and errors to the console. The default is false.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisVerbose" type="msb:boolean" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisVerbose" _locComment="" -->Indicates whether to output verbose Code Analysis diagnostic info to the console. The default is false.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisPath" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisPath" _locComment="" -->Path to the Code Analysis installation folder. The default is '$(VSINSTALLDIR)\Team Tools\Static Analysis Tools\FxCop'.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisPlatformPath" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisPlatformPath" _locComment="" -->Path to the .NET Framework folder that contains platform assemblies, such as mscorlib.dll and System.dll. The default is an empty string ('').</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisProject" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisProject" _locComment="" -->Path to the Code Analysis project (*.fxcop) to load. The default is an empty string ('').</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisQuiet" type="msb:boolean" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisQuiet" _locComment="" -->Indicates whether to suppress all Code Analysis console output other than errors and warnings. This applies when $(CodeAnalysisOutputToConsole) is true. The default is false.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisRuleAssemblies" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisRuleAssemblies" _locComment="" -->Semicolon-separated list of paths either to Code Analysis rule assemblies or to folders that contain Code Analysis rule assemblies. The paths are in the form '[+|-][!][file|folder]', where '+' enables all rules in rule assembly, '-' disables all rules in rule assembly, and '!' causes all rules in rule assembly to be treated as errors. For example '+D:\Projects\Rules\NamingRules.dll;+!D:\Projects\Rules\SecurityRules.dll'. The default is '$(CodeAnalysisPath)\Rules'.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisRuleDirectories" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisRuleDirectories" _locComment="" -->Semicolon-separated list of directories in which to search for rules when resolving a rule set. The default is '$(CodeAnalysisPath)\Rules' unless the CodeAnalysisIgnoreBuiltInRules property is set to true.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisRules" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisRules" _locComment="" -->Semicolon-separated list of Code Analysis rules. The rules are in the form '[+|-][!]Category#CheckId', where '+' enables the rule, '-' disables the rule, and '!' causes the rule to be treated as an error. For example, '-Microsoft.Naming#CA1700;+!Microsoft.Naming#CA1701'. The default is an empty string ('') which enables all rules.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisRuleSet" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisRuleSet" _locComment="" -->A .ruleset file which contains a list of rules to run during analysis. The string can be a full path, a path relative to the project file, or a file name. If a file name is specified, the CodeAnalysisRuleSetDirectories property will be searched to find the file. The default is an empty string ('').</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisRuleSetDirectories" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisRuleSetDirectories" _locComment="" -->Semicolon-separated list of directories in which to search for rule sets. The default is '$(VSINSTALLDIR)\Team Tools\Static Analysis Tools\Rule Sets' unless the CodeAnalysisIgnoreBuiltInRuleSets property is set to true.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisSaveMessagesToReport" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisSaveMessagesToReport" _locComment="" -->Comma-separated list of the type ('Active', 'Excluded', or 'Absent') of warnings and errors to save to the output report file. The default is 'Active'.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisSearchGlobalAssemblyCache" type="msb:boolean" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisSearchGlobalAssemblyCache" _locComment="" -->Indicates whether Code Analysis should search the Global Assembly Cache (GAC) for missing references that are encountered during analysis. The default is true.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisSummary" type="msb:boolean" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisSummary" _locComment="" -->Indicates whether to output a Code Analysis summary to the console after analysis. The default is false.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisTimeout" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisTimeout" _locComment="" -->The time, in seconds, that Code Analysis should wait for analysis of a single item to complete before it aborts analysis. Specify 0 to cause Code Analysis to wait indefinitely. The default is 120.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisTreatWarningsAsErrors" type="msb:boolean" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisTreatWarningsAsErrors" _locComment="" -->Indicates whether to treat all Code Analysis warnings as errors. The default is false.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisUpdateProject" type="msb:boolean" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisUpdateProject" _locComment="" -->Indicates whether to update the Code Analysis project (*.fxcop) specified in $(CodeAnalysisProject). This applies when there are changes during analysis. The default is false.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CodeAnalysisUseTypeNameInSuppression" type="msb:boolean" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation><!-- _locID_text="CodeAnalysisUseTypeNameInSuppression" _locComment="" -->Indicates whether to include the name of the rule when Code Analysis emits a suppression. The default is true.</xs:documentation>
</xs:annotation>
I was unsuccessful with the two answers provided by Matthijs and Nicole Calinoiu, but after further investigation, I stumbled across this question on StackOverflow.
In short, it is not recommended one disable these files from being outputted in general. According to seva titov's answer in that question linked above:
First, removing .lastcodeanalysissucceededd will cause code analysis re-run even when nothing has changed. Second, removing .CodeAnalysisLog.xml will make it almost impossible to investigate details of analysis errors and warnings. So you might as well just turn off the code analysis for the project.
Therefore, it is best to just move these two files to the intermediate file location. This location is where all the *.obj files, *.log files, and other meta files exist. To do this, right click your project and click "Unload Project."
Then, right click the project and click Edit p͟r͟o͟j͟e͟c͟t͟.vcxproj. In the picture, I click Edit Test1.vcxproj, because my project for this demonstration is called Test1:
And then, at the end of the project tag </Project> you will see a bunch of <Import ...> statements. Put the property group described in the question after these import statements:
<PropertyGroup>
<CodeAnalysisLogFile>$(IntermediateOutputPath)$(TargetFileName).CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisSucceededFile>$(IntermediateOutputPath)$(TargetFileName).lastcodeanalysissucceeded</CodeAnalysisSucceededFile>
</PropertyGroup>
For example, it should look something like this:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
...
A lot of other stuff not shown
...
-->
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<!-- The following will move the code analysis output files and put them in the intermediate folder -->
<PropertyGroup>
<CodeAnalysisLogFile>$(IntermediateOutputPath)$(TargetFileName).CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisSucceededFile>$(IntermediateOutputPath)$(TargetFileName).lastcodeanalysissucceeded</CodeAnalysisSucceededFile>
</PropertyGroup>
</Project>
(Note: Keep the contents of both <CodeAnalysisSucceededFile> and <CodeAnalysisLogFile> tags on a single line as shown above. Visual Studio 2019 throws an "Illegal Characters in Path" error, if you put the content across several lines.)
Related
I am receiving a document in Biztalk, which contain some base64 encoded content inside an xml tag.
What I need, is to decode this content (which is a seperate XML document) and insert it into an in an envelope schema, to then be processed further.
The structure of the received document is like so:
<Polling xmlns="http://schemas.microsoft.com/Sql/2008/05/Polling/">
<PolledData>
<DataSet xmlns="http://schemas.datacontract.org/2004/07/System.Data">
<xs:schema id="NewDataSet" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element msdata:IsDataSet="true" name="NewDataSet">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="NewTable">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="ID" type="xs:string"/>
<xs:element minOccurs="0" name="hostUTC" type="xs:dateTime"/>
<xs:element minOccurs="0" name="msgType" type="xs:string"/>
<xs:element minOccurs="0" name="acknowledgment" type="xs:string"/>
<xs:element minOccurs="0" name="sendLog" type="xs:string"/>
<xs:element minOccurs="0" name="msgFormat" type="xs:string"/>
<xs:element minOccurs="0" name="msgbody" type="xs:base64Binary"/>
<xs:element minOccurs="0" name="fromID" type="xs:string"/>
<xs:element minOccurs="0" name="toID" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<NewTable>
<ID>123</ID>
<hostUTC>2018-11-08T14:53:24.11Z</hostUTC>
<msgType>INVOIC</msgType>
<msgFormat>Edifact</msgFormat>
<msgbody>base64encodedmessage...</msgbody>
<fromID>DKT:28504861</fromID>
<toID>KMDoioUBL</toID>
</NewTable>
</NewDataSet>
</diffgr:diffgram>
</DataSet>
</PolledData>
</Polling>
The base64 encoded content is located inside the tag.
I've already created the envelope schema, which has the following structure:
The message is received using a WCF-SQL adapter on a receive location. Currently no pipeline has been set up to process the message. In the 'Messages' tab of the adapter configuration it seems there is an option for base64 encoding, though I am not sure what this does or how it works exactly. When using the body setting here I get returned the above XML.
I'm not sure if this can be done without writing any code.
Reading this post on the subject, it seems that I need to write a custom pipeline component to handle the decoding. But first I would need to extract the content of the specific XML node.
I'm unsure how to approach this problem. I'd like to avoid using orchestrations if at all possible. Can this be done in standard Biztalk, or will I need to create custom functionality to handle this process?
Edit: XPath attempts
/Polling/PolledData[1]/*[namespace-uri()='http://schemas.datacontract.org/2004/07/System.Data' and local-name()='DataSet'][1]/*[namespace-uri()='urn:schemas-microsoft-com:xml-diffgram-v1' and local-name()='diffgram'][1]/*[namespace-uri()='' and local-name()='NewDataSet'][1]/*[namespace-uri()='' and local-name()='NewTable'][1]/*[namespace-uri()='' and local-name()='msgbody'][1]
/*[local-name()='Polling']/*[local-name()='PolledData']/*[local-name()='DataSet']/*[local-name()='diffgram']/*[local-name()='NewDataSet']/*[local-name()='NewTable']/*[local-name()='msgbody']
/Polling/PolledData/DataSet/diffgr:diffgram/NewDataSet/NewTable/msgbody
//*[msgbody]/text()
I am trying to consume a WSDL, generate source form WSDL and XSDs in gradle using org.apache.cxf.tools.wsdlto.WSDLToJava. It generates classname as it is in XSDs and WSDL, but I want change all the generated class names in similar way. I know I can add binding file to it, but I would need to have entry for every element in the WSDL.
Please help me with a generic for all the properties.
e.g XSD below :
<xs:complexType name="SomeType">
<xs:sequence>
<xs:element name="SomeType2" type="CommonNS:Some2Type"/>
<xs:element name="SomeType3" type="CommonNS:Some3Type" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
The classes generated are :
com.something.SomeType
com.something.Some2Type
com.something.Some3Type
But I want to generate it as :
com.something.Some
com.something.Some2
com.something.Some3
I have very little knowledge in xsd and in an urgent need for a solution to a petty problem.
I need to define an element(named tag) which may have any type and number of child elements(and texts as well) but must not contain an empty string.
Example: <tag1> co<sub1>2</sub1> <b1>laser</b1></tag1>,<tag1>co2</tag1>,<tag1><i1>laser</i1></tag1> are allowed (let's say that even <tag1><i1></i1></tag1> is also allowed). But <tag1></tag1> not allowed. Please let me know if there is a very simple way of doing this.
If you are using XSD 1.1, you can use an assertion to check the condition you describe:
<xs:element name="tag" type="non-empty"/>
<xs:complexType name="non-empty">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:any/>
</xs:sequence>
<xs:assert test="child::* or not(string(.) eq '')"/>
</xs:complexType>
In XSD 1.0, there isn't quite such a simple approach; if I were you and working in XSD 1.0, I'd change the design to something easier to express in XSD 1.0.
In 1.0, it's easy to require that the tag element have one or more children, without constraining the children:
<xs:complexType name="non-empty" mixed="true">
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:any/>
</xs:sequence>
</xs:complexType>
<xs:element name="tag" type="non-empty"/>
It's also easy to specify that the tag element can have any non-empty string (I'm taking you at your word here, and allowing strings consisting only of white space -- be careful what you ask for):
<xs:simpleType name="non-empty">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="tag" type="non-empty"/>
What's not possible in 1.0 is (a) declaring an element as having either a simple or a complex type, or (b) constraining the textual content of a complex type with mixed content.
Good luck.
I have a WCF service that expects an object which I'll call StuffContainer. Our client is trying to generate an XML-serialized StuffContainer using JAXB, but it's coming out wrong. They're ending up with type names where they should have property names, so we're not able to deserialize it.
I know nothing about JAXB, but I gather it creates some auto-generated classes based on our XSD, which can be used to build the XML-serialized object.
Here's the relevant snippet of our auto-generated XSD:
<xs:complexType name="StuffContainer">
<xs:sequence>
<xs:element minOccurs="0" name="myStuff" nillable="true" type="tns:ArrayOfStuff"/>
</xs:sequence>
</xs:complexType>
...
<xs:complexType name="ArrayOfStuff">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="Stuff" nillable="true" type="tns:Stuff"/>
</xs:sequence>
</xs:complexType>
Our client's code looks something like this:
ObjectFactory objectFactory = new ObjectFactory();
ArrayOfStuff arrayOfStuff = objectFactory.createArrayOfStuff();
JAXBElement<ArrayOfStuff> arrayOfStuffJAXBElement = objectFactory.createArrayOfStuff(arrayOfStuff);
StuffContainer stuffContainer = objectFactory.createStuffContainer();
stuffContainer.setStuff(arrayOfStuffJAXBElement);
Here's the XML they're getting:
<StuffContainer xmlns="..."><ArrayOfStuff>...</ArrayOfStuff></StuffContainer>
But I need it to be:
<StuffContainer xmlns="..."><myStuff>...</myStuff></StuffContainer>
I think this is because the JAXBElement<ArrayOfStuff> that they're getting from the objectFactory has its QName set to "ArrayOfStuff", and this ends up getting used instead of the property name myStuff. But like I said I know nothing about JAXB so I'm not sure what they should be doing differently.
Is there something either that I can change in the XSD, or that I can ask our client to change in their code, so that it generates the correct XML?
There may be multiple methods on the generated ObjectFactory class. The ones corresponding to nested elements have an entire path built into the method name.
My Xml is not getting correctly validated against the XSD.
I expect the browser to through atleast some kind of generic error messages when i open xml file
My Xml file is below
note.Xml
<?xml version="1.0"?>
<note
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:SchemaLocation="note.xsd">
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
My Xsd file is below
note.xsd
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified"><xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
<xs:attribute name="to" type="xs:string" use="required"/>
</xs:complexType>
</xs:element></xs:schema>
Both the note.xml and note.xsd files are in the same folder.
Can somebody guide why i am not getting any error? So Can anyone help me how to validate my xml file with xsd? Thank you,
Three problems:
xsi:schemaLocation attribute value
should be a white-space separate
sequence of namespace URI and schema
document URI, like xsi:schemaLocation="http://www.w3schools.com note.xsd"
You wrote:
I expect the browser to through
atleast some kind of generic error
It's not clear that you are actually
using some validation tool. No
browser validates XML Schema when
you open an XML document.
Your schema targets the
http://www.w3schools.com namespace
URI, but your document is under null
(or empty) namespace URI. This will
end up in validation error, even if
you use the
xsi:noNamespaceSchemaLocation
instead of the xsi:schemaLocation
attribute. Maybe you want to add a
default namespace declaration in
your input source like
xmlns="http://www.w3schools.com"...