Comments (17)
It seems like I'm getting this error while trying to compile Npgsql. The build output with a stack trace is below, please let me know if I can provide any more info.
(thanks for all the effort making CC work on VS2015!)
1>------ Rebuild All started: Project: Npgsql, Configuration: Debug Any CPU ------
1> AsmMeta failed with uncaught exception: Unknown custom metadata item kind: 7
1> Stack trace: at Microsoft.Cci.Pdb.PdbFunction.ReadCustomMetadata(BitAccess bits)
1> at Microsoft.Cci.Pdb.PdbFunction..ctor(ManProcSym proc, BitAccess bits)
1> at Microsoft.Cci.Pdb.PdbFunction.LoadManagedFunctions(BitAccess bits, UInt32 limit, Boolean readStrings)
1> at Microsoft.Cci.Pdb.PdbFile.LoadFuncsFromDbiModule(BitAccess bits, DbiModuleInfo info, IntHashTable names, ArrayList funcList, Boolean readStrings, MsfDirectory dir, Dictionary`2 nameIndex, PdbReader reader, Dictionary`2 sourceCache)
1> at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, Dictionary`2& tokenToSourceMapping, String& sourceServerData)
1> at Microsoft.Cci.PdbReader..ctor(Stream pdbStream, IMetadataHost host)
1> at AsmMeta.AsmMeta.Run()
1> at AsmMeta.AsmMeta.RealMain(String[] args)
1> at AsmMeta.AsmMeta.Main(String[] args)
1> elapsed time: 226.1501ms
1>C:\Program Files (x86)\Microsoft\Contracts\MsBuild\v14.0\Microsoft.CodeContracts.targets(356,5): error MSB3073: The command ""C:\Program Files (x86)\Microsoft\Contracts\Bin\ccrefgen.exe" "@obj\Debug\Npgsqlccrefgen.rsp"" exited with code 1.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
from codecontracts.
Small repo project would be helpful!
from codecontracts.
I'd love to help, but the stack trace gives no indication at all of where the error is coming from... Do you have some method/pattern of isolation in this case? Or should I simply attempt to cut out code until I manage to isolate?
from codecontracts.
What version are you using? Can you try new release? This one: https://github.com/Microsoft/CodeContracts/releases/tag/v.1.9.10709.0
from codecontracts.
Trying to reproduce and test the fix.
from codecontracts.
I tried to create simple console application and added a dependency to Npgsql. Added new Npgsql.NpgsqlConnection()
but was able to compile this using latest version...
Should I do something else?
from codecontracts.
@SergeyTeplyakov, am using the new version just published (v.1.9.10709.0). Sorry for not being clearer, but the error happens when compiling the project, not when running anything. So just clone the develop branch of Npgsql and try to compile it in VS2015 and you should get the error.
I could go eliminating Contract.Requires
/Contract.Ensures
until the error is gone, this way we isolate the issue - do you have a better idea?
from codecontracts.
No need to remove anything. There is a fix that I didn't apply - #33. So I'll try to apply it locally and then will check is it fixed or not.
from codecontracts.
OK great @SergeyTeplyakov, I'll look out for a new version. Let me know if there's anything else I can help with on this.
from codecontracts.
Thanks, @roji! I'll push an update soon if the fix will solve the issue.
from codecontracts.
Could you please backup your old Contract folder (Program Files x86\Microsoft\Contracts\bin) and unzip this (http://files.rsdn.ru/34036/ccrefgen.zip) new ccrefgen version there. Could you please check it?
from codecontracts.
Hmm, I no longer get the previous issue but I do get some new, async-related ones:
Severity Code Description Project File Line
Error CC1017 Malformed contract section in method 'Npgsql.NpgsqlBuffer+<SkipAsync>d__78.MoveNext' Npgsql C:\projects\npgsql\src\Npgsql\NpgsqlBuffer.cs 600
Error CC1017 Malformed contract section in method 'Npgsql.NpgsqlDataReader+<GetFieldValueInternalAsync>d__133`1.MoveNext' Npgsql C:\projects\npgsql\src\Npgsql\NpgsqlDataReader.cs 1861
Error CC1017 Malformed contract section in method 'Npgsql.NpgsqlLargeObjectStream+<SeekAsync>d__34.MoveNext' Npgsql C:\projects\npgsql\src\Npgsql\NpgsqlLargeObjectStream.cs 300
Error CC1017 Malformed contract section in method 'Npgsql.NpgsqlLargeObjectStream+<SetLengthAsync>d__36.MoveNext' Npgsql C:\projects\npgsql\src\Npgsql\NpgsqlLargeObjectStream.cs 300
Error The command ""C:\Program Files (x86)\Microsoft\Contracts\Bin\ccrewrite.exe" "@Npgsqlccrewrite.rsp"" exited with code 4. Npgsql
Note that the files and line numbers are bogus: these async methods are in GeneratedAsync.cs (there's some code generation going on). In any case, the first methods is simply this:
internal async Task SkipAsync(long len)
{
Contract.Requires(len >= 0);
if (len > ReadBytesLeft)
{
len -= ReadBytesLeft;
while (len > Size)
{
Clear();
await EnsureAsync(Size);
len -= Size;
}
Clear();
await EnsureAsync((int)len);
}
ReadPosition += (int)len;
}
Am not sure what is causing this: a simple async method with Contract.Requires
seems OK... Should I open a different issue and try to isolate?
from codecontracts.
That's a different issue. Thanks. I'll check it. Could you create separate issue for it? And Could you comment requires in this code just to move forward and check for other patterns that could cause issues?
from codecontracts.
OK, opened #112.
Will check with these methods commented out and report back.
from codecontracts.
@SergeyTeplyakov - Just as an FYI, I'm seeing the same issue as roji with the preview release. With your modified ccrefgen from this thread, the errors go away. I'll try out the next release when you get the fix incorporated. Thank you to you and @sharwell for all the hard work you've been doing!
from codecontracts.
The error I received when compiling my project in debug mode is the same as well. I haven't tried the fix yet.
from codecontracts.
Thanks, @sharwell, @jbcutting. I'm working on the fix for #112 and after that will publish a new release.
from codecontracts.
Related Issues (20)
- Rewriter produces incorrect debug information for async methods in PDB file HOT 1
- Removing Code Contracts from a project when upgrading to VS2017 HOT 1
- Rosalyn Code Analyzer for Code Contracts Usage HOT 4
- .NET Framework 4.7 BCL Contracts
- ccrewrite aborted due to metadata errors (Xamarin or VS2017 15.2 related?)
- StackOverflowException in cccheck.exe
- IDictionary contracts and boxing HOT 2
- Postcondition missing from StringBuilder.AppendFormat(IFormatProvider, string, object)
- How to enable "perform runtime contract checking" in Visual Studio 2017? HOT 19
- Do not work with visual studio 2017 HOT 6
- COMException (0x80004005)
- Build with CodeContracts fails with dotnet build
- Document for the implementation/source code?
- Another NullReferenceException with closure in constructor
- VS2017 path to sn.exe is wrong
- Reading assembly 'Unity.Abstractions' generate System.OutOfMemoryException HOT 1
- BadImageFormatException with enabled runtime checking
- Rewrite tool introduce bugs in local functions
- Preconditions with non-interger decimals are broken
- Enable contracts in VS Community 2019
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codecontracts.